You need to sign in to do that
Don't have an account?
Sascha Deinert
Math.Max function
Hi,
I tried to find the max value of some different value. Late I will replace the numbers with variables.
Could you help me please.
Thanks,
Sascha
I tried to find the max value of some different value. Late I will replace the numbers with variables.
MaxValue = Math.max (1,4,5,2,10);Compile Error: Method does not exist or incorrect signature: Math.max(Integer, Integer, Integer, Integer, Integer)
Could you help me please.
Thanks,
Sascha
Hi Sascha,
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_math.htm#apex_System_Math_max_3
Please refer the above link .
it seems the max function is taking only two arguments in apex coding.
But in formula fields it is taking more than one argument.
If this answers your question make this as solution.
Thanks,
Sure.
Can I add the values into an array and than I use the math.max function? I tried, but I geht an error:
Method does not exist or incorrect signature: math.max(List<Integer>)
If this is not possible, how can I find the max value of an array or different variables?
Thanks,
Sascha
If you want to find the maximum or minimum from a list, sort the list first. Default sorting order is ASC.
First element will be minimum and last element in the list will be maximum
Integer[] myList = new List<Integer> { 1,4,5,2,10 };
myList.sort();
MaxValue = mylist[4];
MinValue = mylist[0];
Regards,
Bhanu Mahesh