Java Long example to find the maximum and minimum of numbers using max and min


public static long max(long a,long b)
Returns the greater of two long values as if by calling Math.max.

public static long min(long a,long b)
Returns the smaller of two long values as if by calling Math.min.

Program:
package com.candidjava;

public class LongMaxMin 
{		 	     
	    public static void main(String a[])
	    {
		Long i=8,j=15;
		System.out.println("The maximum value is "+Long.max(i, j));
	    	System.out.println("The minimum value is "+Long.min(i, j));
	    }
}	    

Output:
The maximum value is 15
The minimum value is 8

Description: 
The maximum and minimum values are being found out.

max():
Parameters:
a - the first operand
b - the second operand

Returns:
the greater of a and b

min():
Parameters:
      a - the first operand
      b - the second operand

Returns:
the smaller of a and b




Related Post

Comments


©candidjava.com