Thinking
in
Java
Fourth Edition
TIJ4 published February, 2006
Solution Guide published September 2007
Bruce Eckel
President, MindView, Inc.
Ervin Varga
Ph.D. Computer Science,
University of Novi Sad, Serbia;
Faculty of Technical Sciences
©2007, MindView, Inc.
All Rights Reserved
,Contents
Copyright & Disclamer i
About this Document iii
Unpacking
the Distribution.................. iii
No Exercises in Chapter 1.. iv
Additional exercises........... iv
Installing the Code 1
Using Eclipse....................... 3
Packages & IDEs 5
Left to the Reader 7
Everything is an Object 9
Exercise 1............................. 9
Exercise 2 ............................ 9
Exercise 3 ...........................10
Exercise 4 ...........................10
Exercise 5 ........................... 11
Exercise 6 ........................... 11
Exercise 7 ...........................12
Exercise 8 ...........................13
Exercise 9 ...........................13
Exercise 10 .........................14
Exercise 11 ..........................16
Exercise 12 .........................16
Exercise 13.......................... 17
Exercise 14 ......................... 17
Exercise 15..........................18
Exercise 16 .........................18
Operators 21
Exercise 1............................21
Exercise 2 ...........................21
Exercise 3 .......................... 22
Exercise 4 .......................... 23
Exercise 5 .......................... 24
Exercise 6 .......................... 24
Exercise 7 .......................... 26
v
, Exercise 8 .......................... 27
Exercise 9 .......................... 27
Exercise 10 ........................ 28
Exercise 11 ......................... 29
Exercise 12 .........................31
Exercise 13......................... 33
Exercise 14 ........................ 33
Controlling Execution 35
Exercise 1........................... 35
Exercise 2 .......................... 35
Exercise 3 .......................... 37
Exercise 4 .......................... 38
Exercise 5 .......................... 39
Exercise 6 ...........................41
Exercise 7 .......................... 42
Exercise 8 .......................... 43
Exercise 9 .......................... 45
Exercise 10 ........................ 46
Initialization & Cleanup 49
Exercise 1........................... 49
Exercise 2 .......................... 49
Exercise 3 .......................... 50
Exercise 4 ...........................51
Exercise 5 ...........................51
Exercise 6 .......................... 52
Exercise 7 .......................... 53
Exercise 8 .......................... 54
Exercise 9 .......................... 54
Exercise 10 ........................ 55
Exercise 11 ......................... 55
Exercise 12 ........................ 56
Exercise 13..........................57
Exercise 14 ........................ 58
Exercise 15......................... 58
Exercise 16 ........................ 59
Exercise 17......................... 60
Exercise 18 .........................61
Exercise 19 .........................61
Exercise 20........................ 62
Exercise 21 ........................ 63
Exercise 22 ........................ 63
vi Thinking in Java, 4th Edition Annotated Solution Guide