How to use arraylist

how to use arraylist with two values integer and string I think it is possible only by hasmap

Hi Arvind,
You got it right.
ArrayList Can’t be used here,
HashMap too can’t suffice here as we need to keep values in dec order and HashMap stores data in a random order.
Do you know TreeMap? If yes,TreeMap can serve your purpose As it keeps data in a sorted order.

Second Method(much easier though) is to use a class which will have a String and Integer as its data member.
I hope this resolves your doubt.

I didn’t learned TreeMap yet i tried to google it but i am not getting confidece please help.

the second method which you are talking about need to make a class with data member as string and integer but how can i keep both of binded just that after sorting numerical data the string value attached to it also changes

Just keep both data members inside a class as follows:
private class MyStudent{
String name;
int marks;
}
Above thing is easy now comes the difficult part.
How to sort Class Mystudent on the basis of marks??
Now, to do this You need to learn overriding inbuilt class methods for it.
Much hints can’t be given though.

how can I solve which is not yet taught~

I think you are in online batch?
Please watch lectures on Classes and then Interface and Generics.
if it helps,
Please mark doubt as resolved.

thank you so in every section some problems need concept which are not yet taught ri8!!!?

No only a few questions needs some particular concepts to be taught.
You can either skip it now and come back later Or learn the concept and try to solve.
Please mark the doubt resolved.
Thankyou

please tell me hot to approach

I learnt via google search that comparator interface is used to compare

Yes do basic problems on comparator interface and then try to solve this one.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.