Java Program to Find Greatest Number using Math class
Hi friends, today we will see Java program to find greatest number using Math class
We will use here Java Math class which provides several methods to do mathematics calculations like
max(), min(), sin(), cos(), etc.
So lets see the program.
public class Maximum
{
public static void main(String args[])
{
int a=2, b=5, c=-3;
int maxno=Math.max(a,(Math.max(b,c)));
System.out.println("The greatest number is = " +maxno);
}
}
Output:
The greatest number is = 5
To know more about Java Math class you may visit here.
Comments
Post a Comment