Syntax error Display Minimum and Maximum values of datatype int in Java

Display Minimum and Maximum values of datatype int in Java



To get the minimum value of datatype int in Java, use the following −

Integer.MIN_VALUE

To get the maximum value of datatype int in Java, use the following −

Integer.MAX_VALUE

Let us now implement this in our example.

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      int val1 = 20;
      int val2 = 3000;
      System.out.println("Value1: "+val1);
      System.out.println("Value2: "+val2);
      System.out.println("Maximum value: "+Integer.MIN_VALUE);
      System.out.println("Minimum value: "+Integer.MAX_VALUE);
   }
}

Output

Value1: 20
Value2: 3000
Maximum value: -2147483648
Minimum value: 2147483647
Updated on: 2020-06-26T10:09:07+05:30

213 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements