Skip to content

Instantly share code, notes, and snippets.

@AnnaBoro
Last active November 10, 2015 08:26
Show Gist options
  • Save AnnaBoro/9fc8f651474c72bbf1b9 to your computer and use it in GitHub Desktop.
Save AnnaBoro/9fc8f651474c72bbf1b9 to your computer and use it in GitHub Desktop.
autoboxing
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;
}
}
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