Created
April 12, 2012 14:39
-
-
Save lukaspili/2367803 to your computer and use it in GitHub Desktop.
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
/** | |
* @author Lukasz Piliszczuk <lukasz.pili AT gmail.com> | |
*/ | |
public class Main { | |
public static void main(String... args) { | |
Character character1 = new Character(); | |
character1.hp = 100; | |
Character character2 = character1; | |
character2.hp = 300; | |
System.out.println(character1.hp); // 300 | |
System.out.println(character2.hp); // 300 | |
} | |
} | |
class Character { | |
int hp; | |
} |
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
/** | |
* @author Lukasz Piliszczuk <lukasz.pili AT gmail.com> | |
*/ | |
public class Main { | |
public static void main(String... args) { | |
Character character1 = new Character(); | |
character1.hp = 100; | |
setTo300(character1); | |
System.out.println(character1.hp); // 300 | |
} | |
public static void setTo300(Character character) { | |
character.hp = 300; | |
} | |
} | |
class Character { | |
int hp; | |
} |
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
/** | |
* @author Lukasz Piliszczuk <lukasz.pili AT gmail.com> | |
*/ | |
public class Main { | |
public static void main(String... args) { | |
Character character1 = new Character(); | |
character1.hp = 100; | |
setTo300(character1); | |
System.out.println(character1.hp); | |
} | |
public static void setTo300(Character character) { | |
character = new Character(); | |
character.hp = 300; | |
} | |
} | |
class Character { | |
int hp; | |
} |
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
/** | |
* @author Lukasz Piliszczuk <lukasz.pili AT gmail.com> | |
*/ | |
public class Main { | |
public static void main(String... args) { | |
int i = 1000, j = 1000; | |
System.out.println(i == j); // true | |
Integer v = 1000; | |
Integer w = 1000; | |
System.out.println(v == w); // false | |
System.out.println(v.equals(w)); // true | |
v = 500; // new Integer(500) | |
w = 500; // new Integer(500) | |
System.out.println(v == w); // false | |
v = 127; // new Integer(100) | |
w = 127; // w = v | |
System.out.println(v == w); // true | |
System.out.println(v.equals(w)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment