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
nallaka lasyapriyanallaka lasyapriya 

create a list of numbers and find the biggest number in apex class

Best Answer chosen by nallaka lasyapriya
syed jabeenasyed jabeena
Hi, Lasyapriya,

For Example:
List<Integer> myList = new List<Integer> {99,85,75,786,325};
myList.sort();
Integer MaxValue = myList[myList.size()-1];

system.debug('==MaxValue=='+MaxValue);

 If it is Helpful to you...Plz Mark as Best Answer...

Thanks Regards,
Syed Jabeena

All Answers

Virendra ChouhanVirendra Chouhan
Sort the list and get the max value at size of the list.
Example: 
List<Integer> intList = new List<Integer> { 2,5,10,12,3 }; 
intList.sort(); 
Integer MaxValue = intList[intList.size()-1];

 
syed jabeenasyed jabeena
Hi, Lasyapriya,

For Example:
List<Integer> myList = new List<Integer> {99,85,75,786,325};
myList.sort();
Integer MaxValue = myList[myList.size()-1];

system.debug('==MaxValue=='+MaxValue);

 If it is Helpful to you...Plz Mark as Best Answer...

Thanks Regards,
Syed Jabeena
This was selected as the best answer