Skip to content

Instantly share code, notes, and snippets.

@shuhei

shuhei/Main.java

Created Feb 23, 2020
Embed
What would you like to do?
Java int overflow
public class Main {
public static void main(String[] args) {
System.out.println(Integer.MIN_VALUE); // -2147483648
System.out.println(Integer.MAX_VALUE); // 2147483647
System.out.println(Integer.MAX_VALUE + 1); // -2147483648
System.out.println(-Integer.MIN_VALUE); // -2147483648
System.out.println(-(Integer.MIN_VALUE + 1)); // 2147483647
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.