Get Max Value from Decimal List



List<Decimal> lstofDecimalValues = new List<Decimal>();
lstofDecimalValues.add(55.0);
lstofDecimalValues.add(75.5);
lstofDecimalValues.add(99.3);
Decimal maxvalue = lstofDecimalValues[1];
 system.debug('maxvalue***'+maxvalue);
        For (integer i =0;i<lstofDecimalValues.size();i++)
        {
            
            if( lstofDecimalValues[i] > maxvalue)
                maxvalue = lstofDecimalValues[i]; 
system.debug('maxvaluellll'+maxvalue);            
        }    
system.debug('the max value is'+maxvalue);




Comments

Popular Post

Check Duplicate EmailId when user Insert the Contact

Fetch Picklist value in LWC using Schema class

Send Email using Wrapper Classes in Salesforce.