Last active
November 10, 2015 08:26
-
-
Save AnnaBoro/9fc8f651474c72bbf1b9 to your computer and use it in GitHub Desktop.
autoboxing
This file contains hidden or 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 class Autoboxing1 { | |
public static void main(String[] args) { | |
Integer a = new Integer(5); | |
int b = 10; | |
Autoboxing1 ab = new Autoboxing1(); | |
System.out.println(ab.sum(a.intValue(), b)); | |
} | |
public int sum(int a, int b) { | |
return a + b; | |
} | |
} |
This file contains hidden or 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
package lesson4; | |
public class Autoboxing2 { | |
public static void main(String[] args) { | |
Integer a = 5; | |
int b = 10; | |
Integer c = new Integer(33); | |
Autoboxing2 ab = new Autoboxing2(); | |
System.out.println(ab.sum(c, b)); | |
a = ab.sum(a, b); | |
System.out.println(ab.sum(a, b)); | |
} | |
public int sum(int a, int b) { | |
return a + b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment