Java Write Test Method Uses Ordinary Loop Add Positive Elements List Doubles Test Method S Q37217081

In Java

Write and test a method that uses an ordinary forloop to add up the positive elements in any list ofdoubles.

Test the method on small array-lists and linked-lists to verifythat it works. Then try it on a large linked-list (about 100,000elements) – verify that it runs slowly.

Then try it on a large array-list – verify that it runsquickly.

(b) Repeat (a), but use a for-each loop. Itshould run quickly on both array-lists and linked-lists even ifthey are very large.


Answer


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.