Not getting how to sort

But when i am trying to use listname[index].getSymbol() I am getting error

@visargdesai
which error it is throwing? See when you iterate over ArrayList it is different from array in java only in one context array is static and has property name length by which we can get length of the array. But ArrayList is dynamic data structure so to calculate array length it has function named size are you using this?
otherwise my personal suggestion is use concept of for-each because we don’t have to modify any thing here so no need of indexing.

@akashchhetri Here is the error i am getting when i try to just see if my arraylist contains the information or not:
The method getClosingPrice() is undefined for the type List

hey use get method of array list to retrieve data from array list check this out https://www.geeksforgeeks.org/arraylist-get-method-java-examples/

1 Like