Table of Contents Dedication.............................................................................................................................. 2 What they're saying about Head First..................................................................................... 3 Praise for Head First Java............................................................................................................................................................................................................... 3 Praise for other Head First books co-authored by Kathy and Bert................................................................................................................................................ 3 Other related books from O'Reilly.................................................................................................................................................................................................. 3 Intro....................................................................................................................................... 7 Who is this book for?....................................................................................................................................................................................................................... 7 We know what you're thinking........................................................................................................................................................................................................ 7 And we know what your brain is thinking...................................................................................................................................................................................... 7 Metacognition: thinking about thinking......................................................................................................................................................................................... 7 Here's what WE did:........................................................................................................................................................................................................................ 7 Here's what YOU can do to bend your brain into submission........................................................................................................................................................ 7 What you need for this book:.......................................................................................................................................................................................................... 7 Last-minute things you need to know:............................................................................................................................................................................................ 7 Technical Editors............................................................................................................................................................................................................................. 7 Other people to credit:..................................................................................................................................................................................................................... 7 Just when you thought there wouldn't be any more acknowledgements....................................................................................................................................... 7 Chapter 1. Breaking the Surface............................................................................................ 19 Section 1.1. The Way Java Works.................................................................................................................................................................................................. 20 Section 1.2. What you'll do in Java................................................................................................................................................................................................ 21 Section 1.3. A very brief history of Java........................................................................................................................................................................................ 22 Section 1.4. Sharpen your pencil................................................................................................................................................................................................... 23 Section 1.5. Sharpen your pencil answers..................................................................................................................................................................................... 24 Section 1.6. Code structure in Java............................................................................................................................................................................................... 25 Section 1.7. Anatomy of a class...................................................................................................................................................................................................... 26 Section 1.8. Writing a class with a main........................................................................................................................................................................................ 27 Section 1.9. What can you say in the main method?.................................................................................................................................................................... 28 Section 1.10. Looping and looping and......................................................................................................................................................................................... 29 Section 1.11. there are no Dumb Questions.................................................................................................................................................................................. 30 Section 1.12. Conditional branching.............................................................................................................................................................................................. 31 Section 1.13. Coding a Serious Business Application.................................................................................................................................................................... 32 Section 1.14. Monday morning at Bob's........................................................................................................................................................................................ 33 Section 1.15. Phrase-O-Matic........................................................................................................................................................................................................ 35 Section 1.16. Fireside Chats........................................................................................................................................................................................................... 36 Section 1.17. Exercise: Code Magnets........................................................................................................................................................................................... 38 Section 1.18. Exercise: BE The compiler....................................................................................................................................................................................... 39 Section 1.19. JavaCross 7.0........................................................................................................................................................................................................... 40 Section 1.20. Mixed Messages....................................................................................................................................................................................................... 41 Section 1.21. Pool Puzzle................................................................................................................................................................................................................ 42 Section 1.22. Exercise Solutins: Code Magnets:........................................................................................................................................................................... 43 Chapter 2. A Trip to Objectville............................................................................................. 45 Section 2.1. Chair Wars................................................................................................................................................................................................................. 46 Section 2.2. Brain Power................................................................................................................................................................................................................ 51 Section 2.3. Making your first object............................................................................................................................................................................................ 54 Section 2.4. Making and testing Movie objects............................................................................................................................................................................. 55 Section 2.5. Quick! Get out of main!............................................................................................................................................................................................. 56 Section 2.6. Running the Guessing Game..................................................................................................................................................................................... 58 Section 2.7. Who am I?.................................................................................................................................................................................................................. 63 Chapter 3. Know Your Variables........................................................................................... 67 Section 3.1. Declaring a variable................................................................................................................................................................................................... 68 Section 3.2. "I'd like a double mocha, no, make it an int."........................................................................................................................................................... 69 Section 3.3. You really don't want to spill that............................................................................................................................................................................. 70 Section 3.4. Back away from that keyword!.................................................................................................................................................................................. 71 Section 3.5. This table reserved..................................................................................................................................................................................................... 71 Section 3.6. Controlling your Dog object...................................................................................................................................................................................... 72 Section 3.7. An object reference is just another variable value.................................................................................................................................................... 73 Section 3.8. There are no Dumb Question.................................................................................................................................................................................... 74 Section 3.9. Java Exposed............................................................................................................................................................................................................. 74 Section 3.10. Life on the garbage-collectible heap........................................................................................................................................................................ 75 Section 3.11. Life and death on the heap....................................................................................................................................................................................... 76 Section 3.12. An array is like a tray of cups................................................................................................................................................................................... 77 Section 3.13. Arrays are objects too............................................................................................................................................................................................... 77 Section 3.14. Make an array of Dogs............................................................................................................................................................................................. 78 Section 3.15. Control your Dog...................................................................................................................................................................................................... 79 Section 3.16. A Dog example......................................................................................................................................................................................................... 80 Section 3.17. Exercise: BE the compiler........................................................................................................................................................................................ 81 Section 3.18. Exercise: Code Magnets........................................................................................................................................................................................... 82 Section 3.19. Pool Puzzle............................................................................................................................................................................................................... 83 Section 3.20. A Heap o' Trouble................................................................................................................................................................................................... 84 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 3.21. Five-Minute Mystery............................................................................................................................................................................................... 85 Section 3.22. Exercise Solutions: Code Magnets.......................................................................................................................................................................... 86 Section 3.23. Puzzle Solutions....................................................................................................................................................................................................... 87 Chapter 4. How Objects Behave............................................................................................ 89 Section 4.1. Remember: a class describes what an object knows and what an object does........................................................................................................ 90 Section 4.2. The size affects the bark............................................................................................................................................................................................. 91 Section 4.3. You can send things to a method.............................................................................................................................................................................. 92 Section 4.4. You can get things back from a method.................................................................................................................................................................... 93 Section 4.5. You can send more than one thing to a method....................................................................................................................................................... 94 Section 4.6. there are no Dumb Questions................................................................................................................................................................................... 96 Section 4.7. Reminder: Java cares about type!............................................................................................................................................................................. 96 Section 4.8. Cool things you can do with parameters and return types....................................................................................................................................... 97 Section 4.9. Encapsulation............................................................................................................................................................................................................ 98 Section 4.10. Encapsulating the GoodDog class......................................................................................................................................................................... 100 Section 4.11. How do objects in an array behave?....................................................................................................................................................................... 101 Section 4.12. Declaring and initializing instance variables........................................................................................................................................................ 102 Section 4.13. The difference between instance and local variables............................................................................................................................................ 103 Section 4.14. there are no Dumb Questions................................................................................................................................................................................ 103 Section 4.15. Comparing variables (primitives or references).................................................................................................................................................... 104 Section 4.16. Exercise: BE the compiler...................................................................................................................................................................................... 106 Section 4.17. Who am I?............................................................................................................................................................................................................... 107 Section 4.18. Mixed Messages..................................................................................................................................................................................................... 108 Section 4.19. Pool Puzzle............................................................................................................................................................................................................. 109 Section 4.20. Five Minute Mystery.............................................................................................................................................................................................. 110 Section 4.21. Puzzle Solutions...................................................................................................................................................................................................... 112 Chapter 5. Extra-Strength Methods..................................................................................... 113 Section 5.1. Let's build a Battleship-style game: "Sink a Dot Com"............................................................................................................................................ 114 Section 5.2. First, a high-level design.......................................................................................................................................................................................... 115 Section 5.3. The "Simple Dot Com Game" a gentler introduction.............................................................................................................................................. 116 Section 5.4. Developing a Class.................................................................................................................................................................................................... 117 Section 5.5. BRAIN POWER........................................................................................................................................................................................................ 117 Section 5.6. There are no Dumb Questions................................................................................................................................................................................. 121 Section 5.7. There are no Dumb Questions................................................................................................................................................................................. 124 Section 5.8. Exercise: BE the JVM.............................................................................................................................................................................................. 136 Section 5.9. Exercise: Code Magnets........................................................................................................................................................................................... 137 Section 5.10. Java Cross............................................................................................................................................................................................................... 138 Section 5.11. Exercise Solutions................................................................................................................................................................................................... 140 Chapter 6. Using the Java Library....................................................................................... 143 Section 6.1. In our last chapter, we left you with the cliff-hanger. A bug................................................................................................................................... 144 Section 6.2. So what happened?.................................................................................................................................................................................................. 145 Section 6.3. How do we fix it?...................................................................................................................................................................................................... 146 Section 6.4. Option one is too clunky.......................................................................................................................................................................................... 147 Section 6.5. Option two is a little better, but still pretty clunky................................................................................................................................................. 147 Section 6.6. Wake up and smell the library................................................................................................................................................................................. 150 Section 6.7. Some things you can do with ArrayList................................................................................................................................................................... 151 Section 6.8. there are no Dumb Questions.................................................................................................................................................................................. 153 Section 6.9. Java Exposed............................................................................................................................................................................................................ 153 Section 6.10. Comparing ArrayList to a regular array................................................................................................................................................................ 154 Section 6.11. Comparing ArrayList to a regular array................................................................................................................................................................. 155 Section 6.12. Let's fix the DotCom code...................................................................................................................................................................................... 156 Section 6.13. New and improved DotCom class.......................................................................................................................................................................... 157 Section 6.14. Let's build the REAL game: "Sink a Dot Com"...................................................................................................................................................... 158 Section 6.15. What needs to change?........................................................................................................................................................................................... 159 Section 6.16. Who does what in the DotComBust game (and when)......................................................................................................................................... 160 Section 6.17. Prep code for the real DotComBust class............................................................................................................................................................... 162 Section 6.18. The final version of the Dotcom class.................................................................................................................................................................... 168 Section 6.19. Super Powerful Boolean Expressions.................................................................................................................................................................... 169 Section 6.20. Ready-bake Code................................................................................................................................................................................................... 170 Section 6.21. Ready-bake Code.................................................................................................................................................................................................... 171 Section 6.22. Using the Library (the Java API)........................................................................................................................................................................... 172 Section 6.23. You have to know the full name of the class you want to use in your code.......................................................................................................... 173 Section 6.24. there are no Dumb Questions................................................................................................................................................................................ 173 Section 6.25. there are no Dumb Questions................................................................................................................................................................................ 175 Section 6.26. How to play with the API....................................................................................................................................................................................... 176 Section 6.27. Code Magnets......................................................................................................................................................................................................... 179 Section 6.28. JavaCross 7.0......................................................................................................................................................................................................... 180 Section 6.29. Exercise Solutions.................................................................................................................................................................................................. 181 Section 6.30. JavaCross answers................................................................................................................................................................................................. 182 Chapter 7. Better Living in Objectville................................................................................. 183 Section 7.1. Chair Wars Revisited................................................................................................................................................................................................ 184 Section 7.2. BRAIN POWER........................................................................................................................................................................................................ 185 Section 7.3. there are no Dumb Questions.................................................................................................................................................................................. 194 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 7.4. there are no Dumb Questions.................................................................................................................................................................................. 198 Section 7.5. brain power.............................................................................................................................................................................................................. 206 Section 7.6. there are no Dumb Questions................................................................................................................................................................................. 207 Section 7.7. Exercise: Mixed Messages....................................................................................................................................................................................... 210 Section 7.8. Exercise BE the Compiler......................................................................................................................................................................................... 211 Section 7.9. Exercise Solutions: BE the Compiler....................................................................................................................................................................... 213 Chapter 8. Serious Polymorphism....................................................................................... 215 Section 8.1. Did we forget about something when we designed this?........................................................................................................................................ 216 Section 8.2. BRAIN POWER....................................................................................................................................................................................................... 220 Section 8.3. there are no Dumb Questions................................................................................................................................................................................. 243 Section 8.4. Pool Puzzle.............................................................................................................................................................................................................. 250 Section 8.5. Exercise Solutions.................................................................................................................................................................................................... 251 Chapter 9. Life and Death of an Object................................................................................ 253 Section 9.1. The Stack and the Heap: where things live............................................................................................................................................................. 254 Section 9.2. Methods are stacked................................................................................................................................................................................................ 255 Section 9.3. What about local variables that are objects?.......................................................................................................................................................... 256 Section 9.4. there are no Dumb Questions................................................................................................................................................................................. 256 Section 9.5. If local variables live on the stack, where do instance variables live?.................................................................................................................... 257 Section 9.6. The miracle of object creation................................................................................................................................................................................. 258 Section 9.7. Construct a Duck..................................................................................................................................................................................................... 260 Section 9.8. Initializing the state of a new Duck......................................................................................................................................................................... 261 Section 9.9. there are no Dumb Questions.................................................................................................................................................................................. 261 Section 9.10. Using the constructor to initialize important Duck state..................................................................................................................................... 262 Section 9.11. Make it easy to make a Duck.................................................................................................................................................................................. 263 Section 9.12. Doesn't the compiler always make a no-arg constructor for you? No!................................................................................................................. 264 Section 9.13. there are no Dumb Questions................................................................................................................................................................................ 266 Section 9.14. there are no Dumb Questions................................................................................................................................................................................ 267 Section 9.15. Wait a minute... we never DID talk about superclasses and inheritance and how that all fits in with constructors.......................................... 268 Section 9.16. Making a Hippo means making the Animal and Object parts too....................................................................................................................... 270 Section 9.17. How do you invoke a superclass constructor?....................................................................................................................................................... 271 Section 9.18. Can the child exist before the parents?................................................................................................................................................................. 272 Section 9.19. Superclass constructors with arguments............................................................................................................................................................... 273 Section 9.20. Invoking one overloaded constructor from another............................................................................................................................................ 274 Section 9.21. Now we know how an object is born, but how long does an object live?............................................................................................................. 276 Section 9.22. What about reference variables?........................................................................................................................................................................... 278 Chapter 10. Numbers Matter............................................................................................... 291 Section 10.1. MATH methods: as close as you'll ever get to a global method............................................................................................................................ 292 Section 10.2. The difference between regular (non-static) and static methods......................................................................................................................... 293 Section 10.3. What it means to have a class with static methods............................................................................................................................................... 294 Section 10.4. Static methods can't use non-static (instance) variables!.................................................................................................................................... 295 Section 10.5. Static methods can't use non-static methods, either!........................................................................................................................................... 296 Section 10.6. Static variable: value is the same for ALL instances of the class.......................................................................................................................... 297 Section 10.7. Initializing a static variable................................................................................................................................................................................... 299 Section 10.8. static final variables are constants........................................................................................................................................................................ 300 Section 10.9. final isn't just for static variables........................................................................................................................................................................... 301 Section 10.10. there are no Dumb Questions............................................................................................................................................................................. 302 Section 10.11. Math methods...................................................................................................................................................................................................... 304 Section 10.12. Wrapping a primitive........................................................................................................................................................................................... 305 Section 10.13. Before Java 5.0, YOU had to do the work........................................................................................................................................................... 306 Section 10.14. Autoboxing: blurring the line bet ween primitive and object............................................................................................................................. 307 Section 10.15. Autoboxing works almost everywhere................................................................................................................................................................ 308 Section 10.16. But wait! There's more! Wrappers have static utility methods too!................................................................................................................... 310 Section 10.17. And now in reverse... turning a primitive number into a String.......................................................................................................................... 311 Section 10.18. Number formatting.............................................................................................................................................................................................. 312 Section 10.19. Formatting deconstructed.................................................................................................................................................................................... 313 Section 10.20. The percent (%) says, "insert argument here" (and format it using these instructions)................................................................................... 314 Section 10.21. The format String uses its own little language syntax......................................................................................................................................... 315 Section 10.22. The format specifier............................................................................................................................................................................................. 316 Section 10.23. The only required specifier is for TYPE............................................................................................................................................................... 317 Section 10.24. What happens if I have more than one argument?............................................................................................................................................. 318 Section 10.25. So much for numbers, what about dates?........................................................................................................................................................... 319 Section 10.26. Working with Dates............................................................................................................................................................................................. 320 Section 10.27. Moving backward and for ward in time............................................................................................................................................................... 321 Section 10.28. Getting an object that extends Calendar............................................................................................................................................................. 322 Section 10.29. Working with Calendar objects........................................................................................................................................................................... 323 Section 10.30. Highlights of the Calendar API........................................................................................................................................................................... 324 Section 10.31. Even more Statics!... static imports..................................................................................................................................................................... 325 Section 10.32. Lunar Code Magnets........................................................................................................................................................................................... 330 Chapter 11. Risky Behavior.................................................................................................. 333 Section 11.1. Let's make a Music Machine................................................................................................................................................................................... 334 Section 11.2. We'll start with the basics....................................................................................................................................................................................... 335 Section 11.3. First we need a Sequencer...................................................................................................................................................................................... 336 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 11.4. Something's wrong!................................................................................................................................................................................................ 336 Section 11.5. What happens when a method you want to call (probably in a class you didn't write) is risky?......................................................................... 337 Section 11.6. Methods in Java use exceptions to tell the calling code, "Some thing Bad Happened. I failed."......................................................................... 338 Section 11.7. The compiler needs to know that YOU know you're calling a risky method........................................................................................................ 339 Section 11.8. An exception is an object… of type Exception....................................................................................................................................................... 340 Section 11.9. If it's your code that catches the exception, then whose code throws it?.............................................................................................................. 341 Section 11.10. there are no Dumb Questions.............................................................................................................................................................................. 342 Section 11.11. Flow control in try/catch blocks........................................................................................................................................................................... 344 Section 11.12. Finally: for the things you want to do no matter what........................................................................................................................................ 345 Section 11.13. Sharpen your pencil:Flow Control....................................................................................................................................................................... 346 Section 11.14. Did we mention that a method can throw more than one exception?................................................................................................................ 347 Section 11.15. Exceptions are polymorphic................................................................................................................................................................................. 348 Section 11.16. Multiple catch blocks must be ordered from smallest to biggest........................................................................................................................ 350 Section 11.17. You can't put bigger baskets above smaller baskets............................................................................................................................................. 351 Section 11.18. Sharpen your pencil.............................................................................................................................................................................................. 352 Section 11.19. When you don't want to handle an exception…................................................................................................................................................... 353 Section 11.20. Ducking (by declaring) only delays the inevitable.............................................................................................................................................. 354 Section 11.21. Getting back to our music code…......................................................................................................................................................................... 356 Section 11.22. Code Kitchen......................................................................................................................................................................................................... 357 Section 11.23. Making actual sound............................................................................................................................................................................................ 358 Section 11.24. Your very first sound player app.......................................................................................................................................................................... 360 Section 11.25. Making a MidiEvent (song data).......................................................................................................................................................................... 361 Section 11.26. MIDI message: the heart of a MidiEvent............................................................................................................................................................. 362 Section 11.27. Anatomy of a message.......................................................................................................................................................................................... 362 Section 11.28. Version 2: Using command-line args to experiment with sounds...................................................................................................................... 364 Section 11.29. Exercise: True or False......................................................................................................................................................................................... 366 Section 11.30. Exercise: Code Magnets....................................................................................................................................................................................... 367 Section 11.31. JavaCross 7.0........................................................................................................................................................................................................ 368 Section 11.32. Exercise Solutions: True or False........................................................................................................................................................................ 369 Section 11.33. Code Magnets....................................................................................................................................................................................................... 369 Section 11.34. JavaCross Answers............................................................................................................................................................................................... 370 Chapter 12. A Very Graphic.................................................................................................. 371 Section 12.1. It all starts with a window...................................................................................................................................................................................... 372 Section 12.2. Your first GUI: a button on a frame...................................................................................................................................................................... 373 Section 12.3. Getting a user event............................................................................................................................................................................................... 375 Section 12.4. Getting a button's ActionEvent............................................................................................................................................................................. 378 Section 12.5. There are no Dumb Questions.............................................................................................................................................................................. 380 Section 12.6. Make your own drawing widget............................................................................................................................................................................ 382 Section 12.7. Because life's too short to paint the circle a solid color when there's a gradient blend waiting for you.............................................................. 385 Section 12.8. BULLET POINTS.................................................................................................................................................................................................. 386 Section 12.9. We can get an event............................................................................................................................................................................................... 387 Section 12.10. Let's try it with TWO buttons.............................................................................................................................................................................. 390 Section 12.11. Java Exposed: This weeks interview: Instance of an Inner Class....................................................................................................................... 398 Section 12.12. There are no Dumb Questions............................................................................................................................................................................. 400 Section 12.13. Code Kitchen........................................................................................................................................................................................................ 404 Section 12.14. Exercise: Who am I?............................................................................................................................................................................................. 412 Section 12.15. Exercise: BE the compiler..................................................................................................................................................................................... 413 Section 12.16. Pool Puzzle............................................................................................................................................................................................................ 414 Section 12.17. Exercise Solutions: Who am I?............................................................................................................................................................................. 415 Section 12.18. Pool Puzzle............................................................................................................................................................................................................ 416 Chapter 13. Work on Your Swing......................................................................................... 417 Section 13.1. Swing components.................................................................................................................................................................................................. 418 Section 13.2. Layout Managers.................................................................................................................................................................................................... 419 Section 13.3. How does the layout manager decide?.................................................................................................................................................................. 420 Section 13.4. The Big Three layout managers: border, flow, and box........................................................................................................................................ 421 Section 13.5. there are no Dumb Questions................................................................................................................................................................................ 430 Section 13.6. Playing with Swing components............................................................................................................................................................................ 431 Section 13.7. there are no Dumb Questions................................................................................................................................................................................ 434 Section 13.8. Code Kitchen.......................................................................................................................................................................................................... 436 Section 13.9. Making the BeatBox............................................................................................................................................................................................... 437 Section 13.10. Exercise: Which code goes with which layout?................................................................................................................................................... 442 Section 13.11. Code Fragments.................................................................................................................................................................................................... 443 Chapter 14. Saving Objects.................................................................................................. 447 Section 14.1. Capture the Beat..................................................................................................................................................................................................... 448 Section 14.2. Saving State............................................................................................................................................................................................................ 449 Section 14.3. Writing a serialized object to a file........................................................................................................................................................................ 450 Section 14.4. Data moves in streams from one place to another................................................................................................................................................ 451 Section 14.5. What really happens to an object when it's serialized?......................................................................................................................................... 452 Section 14.6. But what exactly IS an object's state? What needs to be saved?........................................................................................................................... 453 Section 14.7. If you want your class to be serializable, implement Serializable......................................................................................................................... 455 Section 14.8. There are no Dumb Questions.............................................................................................................................................................................. 458 Section 14.9. Deserialization: restoring an object...................................................................................................................................................................... 459 Section 14.10. What happens during deserialization?............................................................................................................................................................... 460 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 14.11. There are no Dumb Questions.............................................................................................................................................................................. 461 Section 14.12. Saving and restoring the game characters........................................................................................................................................................... 462 Section 14.13. The GameCharacter class..................................................................................................................................................................................... 463 Section 14.14. Object Serialization.............................................................................................................................................................................................. 464 Section 14.15. Writing a String to a Text File.............................................................................................................................................................................. 465 Section 14.16. Text File Example: e-Flashcards.......................................................................................................................................................................... 466 Section 14.17. Quiz Card Builder (code outline)......................................................................................................................................................................... 467 Section 14.18. The java.io.File class............................................................................................................................................................................................ 470 Section 14.19. The beauty of buffers............................................................................................................................................................................................ 471 Section 14.20. Reading from a Text File..................................................................................................................................................................................... 472 Section 14.21. Quiz Card Player (code outline)........................................................................................................................................................................... 473 Section 14.22. Parsing with String split()................................................................................................................................................................................... 476 Section 14.23. There are no Dumb Questions............................................................................................................................................................................. 477 Section 14.24. Version ID: A Big Serialization Gotcha............................................................................................................................................................... 478 Section 14.25. Using the serialVersionUID................................................................................................................................................................................. 479 Section 14.26. Code Kitchen....................................................................................................................................................................................................... 480 Section 14.27. Saving a BeatBox pattern..................................................................................................................................................................................... 481 Section 14.28. Restoring a BeatBox pattern............................................................................................................................................................................... 482 Section 14.29. Sharpen your pencil: Can they be saved?........................................................................................................................................................... 483 Section 14.30. Exercise: True or False........................................................................................................................................................................................ 484 Section 14.31. Code Magnets....................................................................................................................................................................................................... 485 Section 14.32. Exercise Solutions............................................................................................................................................................................................... 486 Chapter 15. Make a Connection........................................................................................... 488 Section 15.1. Real-time Beat Box Chat........................................................................................................................................................................................ 489 Section 15.2. Connecting, Sending, and Receiving..................................................................................................................................................................... 491 Section 15.3. Make a network Socket connection....................................................................................................................................................................... 492 Section 15.4. A TCP port is just a number: A 16-bit number that identifies a specific program on the server......................................................................... 493 Section 15.5. To read data from a Socket, use a BufferedReader............................................................................................................................................... 495 Section 15.6. To write data to a Socket, use a PrintWriter......................................................................................................................................................... 496 Section 15.7. DailyAdviceClient code.......................................................................................................................................................................................... 498 Section 15.8. Writing a simple server......................................................................................................................................................................................... 500 Section 15.9. DailyAdviceServer code.......................................................................................................................................................................................... 501 Section 15.10. Writing a Chat Client........................................................................................................................................................................................... 503 Section 15.11. Java has multiple threads but only one Thread class.......................................................................................................................................... 507 Section 15.12. What does it mean to have more than one call stack?........................................................................................................................................ 508 Section 15.13. Every Thread needs a job to do: A method to put on the new thread stack........................................................................................................ 510 Section 15.14. To make a job for your thread, implement the Runnable interface..................................................................................................................... 511 Section 15.15. The Thread Scheduler........................................................................................................................................................................................... 514 Section 15.16. there are no Dumb Questions............................................................................................................................................................................... 517 Section 15.17. Putting a thread to sleep....................................................................................................................................................................................... 518 Section 15.18. Using sleep to make our program more predictable........................................................................................................................................... 519 Section 15.19. Making and starting two threads......................................................................................................................................................................... 520 Section 15.20. What will happen?............................................................................................................................................................................................... 520 Section 15.21. Um, yes. There IS a dark side. Threads can lead to concurrency 'issues'............................................................................................................ 521 Section 15.22. The Ryan and Monica problem, in code.............................................................................................................................................................. 523 Section 15.23. The Ryan and Monica example........................................................................................................................................................................... 524 Section 15.24. We need the makeWithdrawal ( ) method to run as one atomic thing............................................................................................................... 527 Section 15.25. Using an object's lock........................................................................................................................................................................................... 528 Section 15.26. The dreaded "Lost Update" problem................................................................................................................................................................... 529 Section 15.27. Let's run this code................................................................................................................................................................................................ 530 Section 15.28. Make the increment() method atomic. Synchronize it!...................................................................................................................................... 531 Section 15.29. there are no Dumb Questions.............................................................................................................................................................................. 531 Section 15.30. The deadly side of synchronization..................................................................................................................................................................... 533 Section 15.31. New and improved SimpleChatClient.................................................................................................................................................................. 535 Section 15.32. Ready-bake Code: The really really simple Chat Server..................................................................................................................................... 537 Section 15.33. there are no Dumb Questions.............................................................................................................................................................................. 539 Section 15.34. Code Kitchen........................................................................................................................................................................................................ 540 Section 15.35. Exercise: Code Magnets....................................................................................................................................................................................... 541 Section 15.36. Exercise Solutions................................................................................................................................................................................................ 543 Section 15.37. Five-Minute Mystery............................................................................................................................................................................................ 544 Chapter 16. Data structures................................................................................................ 546 Section 16.1. Tracking song popularity on your jukebox............................................................................................................................................................ 547 Section 16.2. Here's what you have so far, without the sort:...................................................................................................................................................... 548 Section 16.3. But the ArrayList class does NOT have a sort() method!..................................................................................................................................... 549 Section 16.4. ArrayList is not the only collection........................................................................................................................................................................ 550 Section 16.5. You could use a TreeSet... Or you could use the Collections.sort() method......................................................................................................... 551 Section 16.6. Adding Collections.sort() to the Jukebox code..................................................................................................................................................... 552 Section 16.7. But now you need Song objects, not just simple Strings....................................................................................................................................... 553 Section 16.8. Changing the Jukebox code to use Songs instead of Strings................................................................................................................................ 554 Section 16.9. It won't compile!.................................................................................................................................................................................................... 555 Section 16.10. The sort() method declaration............................................................................................................................................................................. 555 Section 16.11. Generics means more type-safety......................................................................................................................................................................... 557 Section 16.12. Learning generics................................................................................................................................................................................................. 558 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 16.13. Using generic CLASSES....................................................................................................................................................................................... 559 Section 16.14. Using type parameters with ArrayList................................................................................................................................................................. 560 Section 16.15. Using generic METHODS..................................................................................................................................................................................... 561 Section 16.16. Here's where it gets weird.................................................................................................................................................................................... 562 Section 16.17. Revisiting the sort() method................................................................................................................................................................................ 564 Section 16.18. In generics, "extends" means "extends or implements"...................................................................................................................................... 565 Section 16.19. Finally we know what's wrong............................................................................................................................................................................. 566 Section 16.20. The new, improved, comparable Song class....................................................................................................................................................... 567 Section 16.21. We can sort the list, but....................................................................................................................................................................................... 568 Section 16.22. Using a custom comparator................................................................................................................................................................................. 569 Section 16.23. Updating the Jukebox to use a Comparator........................................................................................................................................................ 570 Section 16.24. Sharpen your pencil: Reverse Engineer.............................................................................................................................................................. 570 Section 16.25. Sharpen your pencil: Fill-in-the-blanks.............................................................................................................................................................. 572 Section 16.26. Uh-oh. The sorting all works, but now we have duplicates................................................................................................................................ 573 Section 16.27. We need a Set instead of a List............................................................................................................................................................................ 574 Section 16.28. The Collection API (part of it)............................................................................................................................................................................. 575 Section 16.29. Using a HashSet instead of ArrayList.................................................................................................................................................................. 576 Section 16.30. What makes two objects equal?........................................................................................................................................................................... 577 Section 16.31. How a HashSet checks for duplicates: hashCode() and equals()........................................................................................................................ 578 Section 16.32. The Song class with overridden hashCode() and equals().................................................................................................................................. 579 Section 16.33. there are no Dumb Questions............................................................................................................................................................................. 580 Section 16.34. And if we want the set to stay sorted, we've got TreeSet..................................................................................................................................... 581 Section 16.35. What you MUST know about TreeSet................................................................................................................................................................. 582 Section 16.36. TreeSet elements MUST be comparable............................................................................................................................................................. 583 Section 16.37. We've seen Lists and Sets, now we'll use a Map.................................................................................................................................................. 584 Section 16.38. Finally, back to generics...................................................................................................................................................................................... 585 Section 16.39. Using polymorphic arguments and generics...................................................................................................................................................... 586 Section 16.40. But will it work with ArrayList<Dog> ?.............................................................................................................................................................. 587 Section 16.41. What could happen if it were allowed................................................................................................................................................................. 588 Section 16.42. Wildcards to the rescue........................................................................................................................................................................................ 591 Section 16.43. Alternate syntax for doing the same thing.......................................................................................................................................................... 592 Section 16.44. there are no Dumb Questions.............................................................................................................................................................................. 592 Section 16.45. Exercise: BE the compiler, advanced.................................................................................................................................................................. 593 Section 16.46. Solution to the "Reverse Engineer" sharpen exercise......................................................................................................................................... 594 Section 16.47. Exercise Solution.................................................................................................................................................................................................. 595 Section 16.48. BE the compiler solution..................................................................................................................................................................................... 596 Chapter 17. Release Your Code............................................................................................ 598 Section 17.1. Deploying your application.................................................................................................................................................................................... 599 Section 17.2. Imagine this scenario............................................................................................................................................................................................ 600 Section 17.3. Separate source code and class files...................................................................................................................................................................... 601 Section 17.4. Put your Java in a JAR.......................................................................................................................................................................................... 602 Section 17.5. Running (executing) the JAR................................................................................................................................................................................ 603 Section 17.6. Put your classes in packages!................................................................................................................................................................................ 604 Section 17.7. Preventing package name conflicts....................................................................................................................................................................... 605 Section 17.8. Compiling and running with packages.................................................................................................................................................................. 607 Section 17.9. The -d flag is even cooler then we said.................................................................................................................................................................. 608 Section 17.10. Making an executable JAR with packages.......................................................................................................................................................... 609 Section 17.11. So where did the manifest file go?........................................................................................................................................................................ 610 Section 17.12. Java Web Start...................................................................................................................................................................................................... 614 Section 17.13. The .jnlp file.......................................................................................................................................................................................................... 616 Section 17.14. Steps for making and deploying a Java Web Start app........................................................................................................................................ 617 Section 17.15. What's First?......................................................................................................................................................................................................... 618 Section 17.16. True or False......................................................................................................................................................................................................... 619 Section 17.17. Summary-Cross 7.0.............................................................................................................................................................................................. 620 Chapter 18. Distributed Computing.................................................................................... 624 Section 18.1. Method calls are always bet ween two objects on the same heap......................................................................................................................... 625 Section 18.2. What if you want to invoke a method on an object running on another machine?............................................................................................. 626 Section 18.3. Object A, running on Little, wants to call a method on Object B, running on Big............................................................................................... 627 Section 18.4. But you can't do that.............................................................................................................................................................................................. 627 Section 18.5. The role of the 'helpers'......................................................................................................................................................................................... 629 Section 18.6. Java RMI gives you the client and service helper objects!.................................................................................................................................... 631 Section 18.7. How does the client get the stub object?............................................................................................................................................................... 637 Section 18.8. How does the client get the stub class?................................................................................................................................................................. 638 Section 18.9. Be sure each machine has the class files it needs................................................................................................................................................. 639 Section 18.10. Sharpen your pencil: What's First?..................................................................................................................................................................... 640 Section 18.11. Yeah, but who really uses RMI?........................................................................................................................................................................... 641 Section 18.12. What about Servlets?........................................................................................................................................................................................... 642 Section 18.13. A very simple Ser vlet........................................................................................................................................................................................... 644 Section 18.14. HTML page with a link to this servlet................................................................................................................................................................. 644 Section 18.15. There are no Dumb Questions............................................................................................................................................................................. 645 Section 18.16. Just for fun, let's make the Phrase-O-Matic work as a servlet............................................................................................................................ 646 Section 18.17. Phrase-O-Matic code, servlet-friendly................................................................................................................................................................. 647 Section 18.18. Enterprise JavaBeans: RMI on steroids.............................................................................................................................................................. 648 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. Section 18.19. For our final trick... a little Jini........................................................................................................................................................................... 649 Section 18.20. Adaptive discovery in action............................................................................................................................................................................... 650 Section 18.21. Self-healing net work in action............................................................................................................................................................................ 652 Section 18.22. Final Project: the Universal Service browser...................................................................................................................................................... 653 Section 18.23. How it works:....................................................................................................................................................................................................... 654 Section 18.24. The classes and interfaces:.................................................................................................................................................................................. 656 Section 18.25. Sharpen your pencil............................................................................................................................................................................................. 661 Section 18.26. Congratulations!.................................................................................................................................................................................................. 665 Appendix A. Final Code Kitchen.......................................................................................... 666 Section A.1. Final BeatBox client program.................................................................................................................................................................................. 667 Appendix B. The Top Ten Topics that almost made it into the Real Book............................. 676 Section B.1. #10 Bit Manipulation............................................................................................................................................................................................... 677 Section B.2. #9 Immutability...................................................................................................................................................................................................... 678 Section B.3. #8 Assertions........................................................................................................................................................................................................... 679 Section B.4. #7 Block Scope........................................................................................................................................................................................................ 680 Section B.5. #6 Linked Invocations............................................................................................................................................................................................. 681 Section B.6. #5 Anonymous and Static Nested Classes............................................................................................................................................................. 682 Section B.7. #5 Anonymous and Static Nested Classes, continued........................................................................................................................................... 683 Section B.8. #4 Access Levels and Access Modifiers (Who Sees What).................................................................................................................................... 684 Section B.9. #4 Access Levels and Access Modifiers, cont......................................................................................................................................................... 684 Section B.10. #3 String and StringBuffer/StringBuilder Methods............................................................................................................................................ 686 Section B.11. #2 Multidimensional Arrays.................................................................................................................................................................................. 687 Section B.12. And the number one topic that didn't quite make it in... #1 Enumerations (also called Enumerated Types or Enums).................................. 688 Section B.13. Using "if" and "switch" with Enums..................................................................................................................................................................... 689 Section B.14. #1 Enumerations, completed................................................................................................................................................................................ 690 Section B.15. Five-Minute Mystery: A Long Trip Home............................................................................................................................................................. 691 Section B.16. Five-Minute Mystery Solution.............................................................................................................................................................................. 692 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. (cid:43)(cid:72)(cid:68)(cid:71)(cid:3)(cid:41)(cid:76)(cid:85)(cid:86)(cid:87)(cid:3)(cid:45)(cid:68)(cid:89)(cid:68)(cid:140) (cid:54)(cid:72)(cid:70)(cid:82)(cid:81)(cid:71)(cid:3)(cid:40)(cid:71)(cid:76)(cid:87)(cid:76)(cid:82)(cid:81) (cid:66)(cid:89)(cid:0)(cid:43)(cid:65)(cid:84)(cid:72)(cid:89)(cid:0)(cid:51)(cid:73)(cid:69)(cid:82)(cid:82)(cid:65)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:34)(cid:69)(cid:82)(cid:84)(cid:0)(cid:34)(cid:65)(cid:84)(cid:69)(cid:83) (cid:35)(cid:79)(cid:80)(cid:89)(cid:82)(cid:73)(cid:71)(cid:72)(cid:84)(cid:0)(cid:165)(cid:0)(cid:18)(cid:16)(cid:16)(cid:19)(cid:12)(cid:0)(cid:18)(cid:16)(cid:16)(cid:21)(cid:0)(cid:66)(cid:89)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:0)(cid:33)(cid:76)(cid:76)(cid:0)(cid:82)(cid:73)(cid:71)(cid:72)(cid:84)(cid:83)(cid:0)(cid:82)(cid:69)(cid:83)(cid:69)(cid:82)(cid:86)(cid:69)(cid:68)(cid:14) (cid:48)(cid:82)(cid:73)(cid:78)(cid:84)(cid:69)(cid:68)(cid:0)(cid:73)(cid:78)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:53)(cid:78)(cid:73)(cid:84)(cid:69)(cid:68)(cid:0)(cid:51)(cid:84)(cid:65)(cid:84)(cid:69)(cid:83)(cid:0)(cid:79)(cid:70)(cid:0)(cid:33)(cid:77)(cid:69)(cid:82)(cid:73)(cid:67)(cid:65)(cid:14) (cid:48)(cid:85)(cid:66)(cid:76)(cid:73)(cid:83)(cid:72)(cid:69)(cid:68)(cid:0)(cid:66)(cid:89)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:12)(cid:0)(cid:17)(cid:16)(cid:16)(cid:21)(cid:0)(cid:39)(cid:82)(cid:65)(cid:86)(cid:69)(cid:78)(cid:83)(cid:84)(cid:69)(cid:73)(cid:78)(cid:0)(cid:40)(cid:73)(cid:71)(cid:72)(cid:87)(cid:65)(cid:89)(cid:0)(cid:46)(cid:79)(cid:82)(cid:84)(cid:72)(cid:12)(cid:0)(cid:51)(cid:69)(cid:66)(cid:65)(cid:83)(cid:84)(cid:79)(cid:80)(cid:79)(cid:76)(cid:12)(cid:0)(cid:35)(cid:33)(cid:0)(cid:25)(cid:21)(cid:20)(cid:23)(cid:18)(cid:14) (cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:0)(cid:66)(cid:79)(cid:79)(cid:75)(cid:83)(cid:0)(cid:77)(cid:65)(cid:89)(cid:0)(cid:66)(cid:69)(cid:0)(cid:80)(cid:85)(cid:82)(cid:67)(cid:72)(cid:65)(cid:83)(cid:69)(cid:68)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:69)(cid:68)(cid:85)(cid:67)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:65)(cid:76)(cid:12)(cid:0)(cid:66)(cid:85)(cid:83)(cid:73)(cid:78)(cid:69)(cid:83)(cid:83)(cid:12)(cid:0)(cid:79)(cid:82)(cid:0)(cid:83)(cid:65)(cid:76)(cid:69)(cid:83)(cid:0)(cid:80)(cid:82)(cid:79)(cid:77)(cid:79)(cid:84)(cid:73)(cid:79)(cid:78)(cid:65)(cid:76)(cid:0)(cid:85)(cid:83)(cid:69)(cid:14)(cid:0) (cid:47)(cid:78)(cid:76)(cid:73)(cid:78)(cid:69)(cid:0)(cid:69)(cid:68)(cid:73)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:0)(cid:65)(cid:82)(cid:69)(cid:0)(cid:65)(cid:76)(cid:83)(cid:79)(cid:0)(cid:65)(cid:86)(cid:65)(cid:73)(cid:76)(cid:65)(cid:66)(cid:76)(cid:69)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:77)(cid:79)(cid:83)(cid:84)(cid:0)(cid:84)(cid:73)(cid:84)(cid:76)(cid:69)(cid:83)(cid:0)(cid:8)(cid:83)(cid:65)(cid:70)(cid:65)(cid:82)(cid:73)(cid:14)(cid:79)(cid:82)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:14)(cid:67)(cid:79)(cid:77)(cid:9)(cid:14)(cid:0)(cid:38)(cid:79)(cid:82)(cid:0)(cid:77)(cid:79)(cid:82)(cid:69)(cid:0)(cid:73)(cid:78)(cid:70)(cid:79)(cid:82)(cid:77)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:12)(cid:0) (cid:67)(cid:79)(cid:78)(cid:84)(cid:65)(cid:67)(cid:84)(cid:0)(cid:79)(cid:85)(cid:82)(cid:0)(cid:67)(cid:79)(cid:82)(cid:80)(cid:79)(cid:82)(cid:65)(cid:84)(cid:69)(cid:15)(cid:73)(cid:78)(cid:83)(cid:84)(cid:73)(cid:84)(cid:85)(cid:84)(cid:73)(cid:79)(cid:78)(cid:65)(cid:76)(cid:0)(cid:83)(cid:65)(cid:76)(cid:69)(cid:83)(cid:0)(cid:68)(cid:69)(cid:80)(cid:65)(cid:82)(cid:84)(cid:77)(cid:69)(cid:78)(cid:84)(cid:26)(cid:0)(cid:8)(cid:24)(cid:16)(cid:16)(cid:9)(cid:0)(cid:25)(cid:25)(cid:24)(cid:13)(cid:25)(cid:25)(cid:19)(cid:24)(cid:0)(cid:79)(cid:82)(cid:0)(cid:67)(cid:79)(cid:82)(cid:80)(cid:79)(cid:82)(cid:65)(cid:84)(cid:69)(cid:32)(cid:79)(cid:82)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:14)(cid:67)(cid:79)(cid:77)(cid:14) (cid:40)(cid:71)(cid:76)(cid:87)(cid:82)(cid:85)(cid:29)(cid:0)(cid:0) (cid:0) (cid:45)(cid:73)(cid:75)(cid:69)(cid:0)(cid:44)(cid:79)(cid:85)(cid:75)(cid:73)(cid:68)(cid:69)(cid:83) (cid:38)(cid:82)(cid:89)(cid:72)(cid:85)(cid:3)(cid:39)(cid:72)(cid:86)(cid:76)(cid:74)(cid:81)(cid:72)(cid:85)(cid:29)(cid:0)(cid:0) (cid:37)(cid:68)(cid:73)(cid:69)(cid:0)(cid:38)(cid:82)(cid:69)(cid:69)(cid:68)(cid:77)(cid:65)(cid:78) (cid:44)(cid:81)(cid:87)(cid:72)(cid:85)(cid:76)(cid:82)(cid:85)(cid:3)(cid:39)(cid:72)(cid:86)(cid:76)(cid:74)(cid:81)(cid:72)(cid:85)(cid:86)(cid:29)(cid:0)(cid:0)(cid:43)(cid:65)(cid:84)(cid:72)(cid:89)(cid:0)(cid:51)(cid:73)(cid:69)(cid:82)(cid:82)(cid:65)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:34)(cid:69)(cid:82)(cid:84)(cid:0)(cid:34)(cid:65)(cid:84)(cid:69)(cid:83) (cid:51)(cid:85)(cid:76)(cid:81)(cid:87)(cid:76)(cid:81)(cid:74)(cid:3)(cid:43)(cid:76)(cid:86)(cid:87)(cid:82)(cid:85)(cid:92)(cid:29) (cid:45)(cid:65)(cid:89)(cid:0)(cid:18)(cid:16)(cid:16)(cid:19)(cid:26)(cid:0) (cid:38)(cid:73)(cid:82)(cid:83)(cid:84)(cid:0)(cid:37)(cid:68)(cid:73)(cid:84)(cid:73)(cid:79)(cid:78)(cid:14) (cid:38)(cid:69)(cid:66)(cid:82)(cid:85)(cid:65)(cid:82)(cid:89)(cid:0)(cid:18)(cid:16)(cid:16)(cid:21)(cid:26)(cid:0) (cid:51)(cid:69)(cid:67)(cid:79)(cid:78)(cid:68)(cid:0)(cid:37)(cid:68)(cid:73)(cid:84)(cid:73)(cid:79)(cid:78)(cid:14) (cid:8)(cid:57)(cid:79)(cid:85)(cid:0)(cid:77)(cid:73)(cid:71)(cid:72)(cid:84)(cid:0)(cid:87)(cid:65)(cid:78)(cid:84)(cid:0)(cid:84)(cid:79)(cid:0)(cid:80)(cid:73)(cid:67)(cid:75)(cid:0)(cid:85)(cid:80)(cid:0)(cid:65)(cid:0)(cid:67)(cid:79)(cid:80)(cid:89)(cid:0)(cid:79)(cid:70)(cid:0)(cid:66)(cid:79)(cid:84)(cid:72)(cid:0)(cid:69)(cid:68)(cid:73)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:14)(cid:14)(cid:14)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:89)(cid:79)(cid:85)(cid:82)(cid:0)(cid:75)(cid:73)(cid:68)(cid:83)(cid:14)(cid:0)(cid:52)(cid:72)(cid:73)(cid:78)(cid:75)(cid:0)(cid:69)(cid:34)(cid:65)(cid:89)(cid:169)(cid:9) (cid:52)(cid:72)(cid:69)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:76)(cid:79)(cid:71)(cid:79)(cid:0)(cid:73)(cid:83)(cid:0)(cid:65)(cid:0)(cid:82)(cid:69)(cid:71)(cid:73)(cid:83)(cid:84)(cid:69)(cid:82)(cid:69)(cid:68)(cid:0)(cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:0)(cid:79)(cid:70)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:0)(cid:42)(cid:65)(cid:86)(cid:65)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:65)(cid:76)(cid:76)(cid:0)(cid:42)(cid:65)(cid:86)(cid:65)(cid:13)(cid:66)(cid:65)(cid:83)(cid:69)(cid:68)(cid:0) (cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:83)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:76)(cid:79)(cid:71)(cid:79)(cid:83)(cid:0)(cid:65)(cid:82)(cid:69)(cid:0)(cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:83)(cid:0)(cid:79)(cid:82)(cid:0)(cid:82)(cid:69)(cid:71)(cid:73)(cid:83)(cid:84)(cid:69)(cid:82)(cid:69)(cid:68)(cid:0)(cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:83)(cid:0)(cid:79)(cid:70)(cid:0)(cid:51)(cid:85)(cid:78)(cid:0)(cid:45)(cid:73)(cid:67)(cid:82)(cid:79)(cid:83)(cid:89)(cid:83)(cid:84)(cid:69)(cid:77)(cid:83)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:12)(cid:0)(cid:73)(cid:78)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0) (cid:53)(cid:78)(cid:73)(cid:84)(cid:69)(cid:68)(cid:0)(cid:51)(cid:84)(cid:65)(cid:84)(cid:69)(cid:83)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:79)(cid:84)(cid:72)(cid:69)(cid:82)(cid:0)(cid:67)(cid:79)(cid:85)(cid:78)(cid:84)(cid:82)(cid:73)(cid:69)(cid:83)(cid:14)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:0)(cid:73)(cid:83)(cid:0)(cid:73)(cid:78)(cid:68)(cid:69)(cid:80)(cid:69)(cid:78)(cid:68)(cid:69)(cid:78)(cid:84)(cid:0)(cid:79)(cid:70)(cid:0)(cid:51)(cid:85)(cid:78)(cid:0)(cid:45)(cid:73)(cid:67)(cid:82)(cid:79)(cid:83)(cid:89)(cid:83)(cid:84)(cid:69)(cid:77)(cid:83)(cid:14) (cid:45)(cid:65)(cid:78)(cid:89)(cid:0)(cid:79)(cid:70)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:68)(cid:69)(cid:83)(cid:73)(cid:71)(cid:78)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:0)(cid:85)(cid:83)(cid:69)(cid:68)(cid:0)(cid:66)(cid:89)(cid:0)(cid:77)(cid:65)(cid:78)(cid:85)(cid:70)(cid:65)(cid:67)(cid:84)(cid:85)(cid:82)(cid:69)(cid:82)(cid:83)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:83)(cid:69)(cid:76)(cid:76)(cid:69)(cid:82)(cid:83)(cid:0)(cid:84)(cid:79)(cid:0)(cid:68)(cid:73)(cid:83)(cid:84)(cid:73)(cid:78)(cid:71)(cid:85)(cid:73)(cid:83)(cid:72)(cid:0)(cid:84)(cid:72)(cid:69)(cid:73)(cid:82)(cid:0)(cid:80)(cid:82)(cid:79)(cid:68)(cid:85)(cid:67)(cid:84)(cid:83)(cid:0)(cid:65)(cid:82)(cid:69)(cid:0) (cid:67)(cid:76)(cid:65)(cid:73)(cid:77)(cid:69)(cid:68)(cid:0)(cid:65)(cid:83)(cid:0)(cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:83)(cid:14) (cid:55)(cid:72)(cid:69)(cid:82)(cid:69)(cid:0)(cid:84)(cid:72)(cid:79)(cid:83)(cid:69)(cid:0)(cid:68)(cid:69)(cid:83)(cid:73)(cid:71)(cid:78)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:0)(cid:65)(cid:80)(cid:80)(cid:69)(cid:65)(cid:82)(cid:0)(cid:73)(cid:78)(cid:0)(cid:84)(cid:72)(cid:73)(cid:83)(cid:0)(cid:66)(cid:79)(cid:79)(cid:75)(cid:12)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:47)(cid:7)(cid:50)(cid:69)(cid:73)(cid:76)(cid:76)(cid:89)(cid:0)(cid:45)(cid:69)(cid:68)(cid:73)(cid:65)(cid:12)(cid:0)(cid:41)(cid:78)(cid:67)(cid:14)(cid:0)(cid:87)(cid:65)(cid:83)(cid:0)(cid:65)(cid:87)(cid:65)(cid:82)(cid:69)(cid:0)(cid:79)(cid:70)(cid:0)(cid:65)(cid:0)(cid:84)(cid:82)(cid:65)(cid:68)(cid:69)(cid:77)(cid:65)(cid:82)(cid:75)(cid:0) (cid:67)(cid:76)(cid:65)(cid:73)(cid:77)(cid:12)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:68)(cid:69)(cid:83)(cid:73)(cid:71)(cid:78)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:0)(cid:72)(cid:65)(cid:86)(cid:69)(cid:0)(cid:66)(cid:69)(cid:69)(cid:78)(cid:0)(cid:80)(cid:82)(cid:73)(cid:78)(cid:84)(cid:69)(cid:68)(cid:0)(cid:73)(cid:78)(cid:0)(cid:67)(cid:65)(cid:80)(cid:83)(cid:0)(cid:79)(cid:82)(cid:0)(cid:73)(cid:78)(cid:73)(cid:84)(cid:73)(cid:65)(cid:76)(cid:0)(cid:67)(cid:65)(cid:80)(cid:83)(cid:14) (cid:55)(cid:72)(cid:73)(cid:76)(cid:69)(cid:0)(cid:69)(cid:86)(cid:69)(cid:82)(cid:89)(cid:0)(cid:80)(cid:82)(cid:69)(cid:67)(cid:65)(cid:85)(cid:84)(cid:73)(cid:79)(cid:78)(cid:0)(cid:72)(cid:65)(cid:83)(cid:0)(cid:66)(cid:69)(cid:69)(cid:78)(cid:0)(cid:84)(cid:65)(cid:75)(cid:69)(cid:78)(cid:0)(cid:73)(cid:78)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:80)(cid:82)(cid:69)(cid:80)(cid:65)(cid:82)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:0)(cid:79)(cid:70)(cid:0)(cid:84)(cid:72)(cid:73)(cid:83)(cid:0)(cid:66)(cid:79)(cid:79)(cid:75)(cid:12)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:80)(cid:85)(cid:66)(cid:76)(cid:73)(cid:83)(cid:72)(cid:69)(cid:82)(cid:0)(cid:65)(cid:78)(cid:68)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0) (cid:65)(cid:85)(cid:84)(cid:72)(cid:79)(cid:82)(cid:83)(cid:0)(cid:65)(cid:83)(cid:83)(cid:85)(cid:77)(cid:69)(cid:0)(cid:78)(cid:79)(cid:0)(cid:82)(cid:69)(cid:83)(cid:80)(cid:79)(cid:78)(cid:83)(cid:73)(cid:66)(cid:73)(cid:76)(cid:73)(cid:84)(cid:89)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:69)(cid:82)(cid:82)(cid:79)(cid:82)(cid:83)(cid:0)(cid:79)(cid:82)(cid:0)(cid:79)(cid:77)(cid:73)(cid:83)(cid:83)(cid:73)(cid:79)(cid:78)(cid:83)(cid:12)(cid:0)(cid:79)(cid:82)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:68)(cid:65)(cid:77)(cid:65)(cid:71)(cid:69)(cid:83)(cid:0)(cid:82)(cid:69)(cid:83)(cid:85)(cid:76)(cid:84)(cid:73)(cid:78)(cid:71)(cid:0)(cid:70)(cid:82)(cid:79)(cid:77)(cid:0)(cid:84)(cid:72)(cid:69)(cid:0)(cid:85)(cid:83)(cid:69)(cid:0)(cid:79)(cid:70)(cid:0) (cid:84)(cid:72)(cid:69)(cid:0)(cid:73)(cid:78)(cid:70)(cid:79)(cid:82)(cid:77)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:0)(cid:67)(cid:79)(cid:78)(cid:84)(cid:65)(cid:73)(cid:78)(cid:69)(cid:68)(cid:0)(cid:72)(cid:69)(cid:82)(cid:69)(cid:73)(cid:78)(cid:14) (cid:41)(cid:78)(cid:0)(cid:79)(cid:84)(cid:72)(cid:69)(cid:82)(cid:0)(cid:87)(cid:79)(cid:82)(cid:68)(cid:83)(cid:12)(cid:0)(cid:73)(cid:70)(cid:0)(cid:89)(cid:79)(cid:85)(cid:0)(cid:85)(cid:83)(cid:69)(cid:0)(cid:65)(cid:78)(cid:89)(cid:84)(cid:72)(cid:73)(cid:78)(cid:71)(cid:0)(cid:73)(cid:78)(cid:0)(cid:40)(cid:69)(cid:65)(cid:68)(cid:0)(cid:38)(cid:73)(cid:82)(cid:83)(cid:84)(cid:0)(cid:42)(cid:65)(cid:86)(cid:65)(cid:169)(cid:0)(cid:84)(cid:79)(cid:12)(cid:0)(cid:83)(cid:65)(cid:89)(cid:12)(cid:0)(cid:82)(cid:85)(cid:78)(cid:0)(cid:65)(cid:0)(cid:78)(cid:85)(cid:67)(cid:76)(cid:69)(cid:65)(cid:82)(cid:0)(cid:80)(cid:79)(cid:87)(cid:69)(cid:82)(cid:0)(cid:80)(cid:76)(cid:65)(cid:78)(cid:84)(cid:0)(cid:79)(cid:82)(cid:0)(cid:65)(cid:73)(cid:82)(cid:0) (cid:84)(cid:82)(cid:65)(cid:70)(cid:108)(cid:67)(cid:0)(cid:67)(cid:79)(cid:78)(cid:84)(cid:82)(cid:79)(cid:76)(cid:0)(cid:83)(cid:89)(cid:83)(cid:84)(cid:69)(cid:77)(cid:12)(cid:0)(cid:89)(cid:79)(cid:85)(cid:7)(cid:82)(cid:69)(cid:0)(cid:79)(cid:78)(cid:0)(cid:89)(cid:79)(cid:85)(cid:82)(cid:0)(cid:79)(cid:87)(cid:78)(cid:14)(cid:0) (cid:41)(cid:51)(cid:34)(cid:46)(cid:26)(cid:0)(cid:16)(cid:21)(cid:25)(cid:22)(cid:16)(cid:16)(cid:25)(cid:18)(cid:16)(cid:24) (cid:59)(cid:45)(cid:61) Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved. (cid:52)(cid:79)(cid:0)(cid:79)(cid:85)(cid:82)(cid:0)(cid:66)(cid:82)(cid:65)(cid:73)(cid:78)(cid:83)(cid:12)(cid:0)(cid:70)(cid:79)(cid:82)(cid:0)(cid:65)(cid:76)(cid:87)(cid:65)(cid:89)(cid:83)(cid:0)(cid:66)(cid:69)(cid:73)(cid:78)(cid:71)(cid:0)(cid:84)(cid:72)(cid:69)(cid:82)(cid:69) Licensed by (cid:8)(cid:68)(cid:69)(cid:83)(cid:80)(cid:73)(cid:84)(cid:69)(cid:0)(cid:83)(cid:72)(cid:65)(cid:75)(cid:89)(cid:0)(cid:69)(cid:86)(cid:73)(cid:68)(cid:69)(cid:78)(cid:67)(cid:69)(cid:9) Eduard Simons 104038 Head First Java, 2nd Edition. Head First Java, 2nd Edition, ISBN: 0596009208 Prepared for [email protected], Eduard Simons Copyright © 2005 Bert Bates and Kathy Sierra. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use requires prior written consent from the copyright owner. Unauthorized use, reproduction and/or distribution are strictly prohibited and violate applicable laws. All rights reserved.
Description: