Java code from text books