Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java max value between two numbers

//Using the built in Math library, you will have two options:

//import the library and then use the function
//(this is useful when your are going to use other functions defined in
//	java.lang.Math, such as "abs" or "min" ...)
import java.lang.Math;
public class MyClass {
    public static void main(String args[]) {
      int x=10;
      int y=25;
      int z= max(x, y);

      System.out.println("The max between the two values is " + z);
    }
}

//otherwise if you just need it once you can directly call 
//the function from the library
public class MyClass {
    public static void main(String args[]) {
      int x=10;
      int y=25;
      int z= Math.max(x, y);

      System.out.println("Sum of x+y = " + z);
    }
}
 
PREVIOUS NEXT
Tagged: #java #max #numbers
ADD COMMENT
Topic
Name
4+7 =