본문 바로가기
Backend/Java

[Java] 정수 최대값, 최소값 구하기

by unknownomad 2022. 3. 28.

정수 최대값, 최소값

최대값 최소값
231-1 (2,147,483,647) -231 (-2,147,483,648)

Integer 클래스

  • int의 Wrapper 클래스인 Integer 클래스 통해 정수의 최대값, 최소값 구할 수 있음
static int Integer.MAX_VALUE
static int Integer.MIN_VALUE


예제

public class IntegerMaxMin {
    public static void main(String[] args) {
    
        System.out.println(Integer.MAX_VALUE); //2147483647
        System.out.println(Integer.MIN_VALUE); //-2147483648
    }
}

 


출처 : https://hianna.tistory.com/583

댓글