Created
August 20, 2020 19:11
-
-
Save Audhil/e24924346d2e2a55a7011d19cb8194a6 to your computer and use it in GitHub Desktop.
wrapper classes - (auto)boxing & (auto)unboxing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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