Skip to content

Instantly share code, notes, and snippets.

@Audhil
Created August 20, 2020 19:11
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 Audhil/e24924346d2e2a55a7011d19cb8194a6 to your computer and use it in GitHub Desktop.
Save Audhil/e24924346d2e2a55a7011d19cb8194a6 to your computer and use it in GitHub Desktop.
wrapper classes - (auto)boxing & (auto)unboxing
public static void main(String[] args) {
int i = 10;
Integer ii = new Integer(i); // boxing - putting primitive type in wrapper classes
Integer iii = i; // auto-boxing - putting primitive type in wrapper classes
int j = ii.intValue(); // unboxing - getting primitive type from wrapper classes
int jj = iii; // auto-unboxing - gettingg primitive types from wrapper classes
System.out.println(i);
System.out.println(ii);
System.out.println(iii);
System.out.println(j);
System.out.println(jj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment