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
| rbo = new ReallyBigObject(); | |
| // more code here | |
| rbo = null; | |
| /* insert code here */ |
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 GC { | |
| private Object o; | |
| private void doSomethingElse(Object obj) { | |
| o = obj; | |
| } | |
| public void doSomething() { | |
| Object o = new Object(); | |
| doSomethingElse(o); |
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 Test { | |
| public static void main(String[] args) { | |
| Short s = 15; | |
| Boolean b; | |
| // insert code here | |
| } | |
| } |
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 Test { | |
| public static void main(String[] args) { | |
| Integer i = 42; | |
| String s = (i < 40) ? "life" : (i > 50) ? "universe" : "everything"; | |
| System.out.println(s); | |
| } | |
| } |
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 Test { | |
| public static void main(String[] args) { | |
| Test t = new Test(); | |
| t.getValue(); | |
| } | |
| public int getValue() { | |
| int value = 0; | |
| boolean setting = true; | |
| String title = "Hello"; |
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 Test { | |
| public static void main(String[] args) { | |
| int x = 5; | |
| Test t = new Test(); | |
| t.doStuff(x); | |
| System.out.print(" main x = " + x); | |
| } | |
| void doStuff(int x) { | |
| System.out.print(" doStuff x = " + x++); |
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 Test { | |
| void doStuff(int x) { | |
| System.out.print(" doStuff x = " + x++); | |
| } | |
| public void main(String[] args) { | |
| int x = 6; | |
| Test p = new Test(); | |
| p.doStuff(x); | |
| System.out.print(" main x = " + x); |
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 com.ocjp; | |
| public class Test { | |
| public static void main(String[] args) { | |
| int x = 5; | |
| boolean b1 = true; | |
| boolean b2 = false; | |
| if ((x == 4) && !b2) | |
| System.out.print("1 "); |
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 IOTest { | |
| public static void main(String[] args) { | |
| SpecialSerial s = new SpecialSerial(); | |
| try { | |
| ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("myFile")); | |
| os.writeObject(s); | |
| os.close(); | |
| System.out.print(++s.z + " "); | |
| ObjectInputStream is = new ObjectInputStream(new FileInputStream("myFile")); | |
| SpecialSerial s2 = (SpecialSerial) is.readObject(); |
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 IOTest { | |
| static String[] dirs = { "dir1", "dir2" }; | |
| public static void main(String[] args) { | |
| for (String d : dirs) { | |
| // insert code 1 here | |
| File file = new File(path, args[0]); | |
| // insert code 2 here | |
| } | |
| } |