Java program to find maximum number using math class

Java program to find greatest number using math class

Java program to find maximum number using math operation

Java program to find maximum number using math.min

Program:-

import java.util.Scanner;

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num1,num2,num;
System.out.println("Enter 1st number");
num1=data.nextInt();
System.out.println("Enter 2nd number");
num2=data.nextInt();
// Finding max number
num=Math.max(num1,num2);
System.out.println("max number:"+num);
}
}


Output:-

Enter 1st number
8
Enter 2nd number
2
max number:8


Output:-

Enter 1st number
5
Enter 2nd number
31
max number:31

Output:-

Enter 1st number
5
Enter 2nd number
5
max number:5





Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top