File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// Recover a serialized file
6+ // {main: serialization.xfiles.ThawAlien}
7+ // {RunFirst: FreezeAlien}
68package serialization .xfiles ;
79import java .io .*;
810
911public class ThawAlien {
1012 public static void
1113 main (String [] args ) throws Exception {
1214 ObjectInputStream in = new ObjectInputStream (
13- new FileInputStream (new File (".." , " X.file" )));
15+ new FileInputStream (new File ("X.file" )));
1416 Object mystery = in .readObject ();
1517 System .out .println (mystery .getClass ());
1618 }
Original file line number Diff line number Diff line change 22// (c)2016 MindView LLC: see Copyright.txt
33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+ // {main: staticchecking.dr.DogsAndRobots}
56package staticchecking .dr ;
67
78interface Speaks { void talk (); }
Original file line number Diff line number Diff line change 22// (c)2016 MindView LLC: see Copyright.txt
33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+ // {main: staticchecking.drc.DogAndRobotCollections}
56package staticchecking .drc ;
67import java .util .*;
78
Original file line number Diff line number Diff line change 22// (c)2016 MindView LLC: see Copyright.txt
33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+ // {main: staticchecking.latent.Latent}
56package staticchecking .latent ;
67import java .lang .reflect .*;
78
Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// Speaking pets in Java
6+ // {main: staticchecking.petspeak.PetSpeak}
67package staticchecking .petspeak ;
78
89interface Pet {
Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// The difference between instanceof and class
6+ // {main: typeinfo.FamilyVsExactType}
67package typeinfo ;
78
89class Base {}
Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// Using class literals
6+ // {main: typeinfo.pets.LiteralPetCreator}
67package typeinfo .pets ;
78import java .util .*;
89
Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// Testing class Class
6+ // {main: typeinfo.toys.GenericToyTest}
67package typeinfo .toys ;
78
89public class GenericToyTest {
Original file line number Diff line number Diff line change 33// We make no guarantees that this code is fit for any purpose.
44// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55// Testing class Class
6+ // {main: typeinfo.toys.ToyTest}
67package typeinfo .toys ;
78
89interface HasBatteries {}
You can’t perform that action at this time.
0 commit comments