function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
❤Code❤Code 

How to get value present in max index in List<String> using Map!!!!!!!

Hi All,


How to get value present in max index in List<String> using Map!!!!!!!.. Can anybody share some examples..

Regards
Chandra Prakash PandeyChandra Prakash Pandey
Hi There,

Let say your List of strings object name is objStringList. Now if you want to access the max index value, you can try:

objStringList[objStringList.size() - 1]

By this you'll get the value stored on the last(max) index.

Let me know, If it helps you.

Regards,
Chandra Prakash
Ganesh HembramGanesh Hembram
Check the below Code snippets.
List<String> ls = new list<String>();
 ls.add('Test 1');
 ls.add('Test 2');
 ls.add('Test 3');
 System.debug('<<Set Value>> '+ls);
 Integer m = ls.size();
Map<Integer, String> j = new Map<Integer, String>();
 for(Integer i=0; i<m; i++) {
     j.put(i,ls[i]);
 }
Integer k = j.size()-1;
String l = j.get(k);
System.debug('<< Value >> '+l);
Hope this helps you.

Regards,
Ganesh