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