Skip to content

Instantly share code, notes, and snippets.

@KylePiira
Created September 24, 2018 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KylePiira/61c521ba513cc24c0145f8560344285f to your computer and use it in GitHub Desktop.
Save KylePiira/61c521ba513cc24c0145f8560344285f to your computer and use it in GitHub Desktop.
Simple Java program to test integer division.
public class IntDivision {
public static void main(String[] args) {
System.out.println("int / int = int");
System.out.println("1 / 3 = " + 1 / 3);
System.out.println("int / double = double");
System.out.println("1 / 3. = " + 1 / 3.);
System.out.println("Another Example:");
Integer v1 = 1 / 1;
Double v2 = 1 / 1.;
System.out.println("1 / 1 = " + v1);
System.out.println("1 / 1. = " + v2);
System.out.println(v1.getClass());
System.out.println(v2.getClass());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment