0%

What will you learn from this book?

Ready to learn Java? This book combines puzzles, strong visuals, mysteries, and soul-searching interviews with famous Java objects to engage you in many different ways. It's fast, it's fun, and it's effective. And despite its playful appearance, Head First Java is serious stuff: a complete introduction to object-oriented programming and Java. You'll learn everything from the fundamentals to advanced topics.

The new third edition brings the book up-to-date for Java 8-17, including major recent updates to the Java language and development platform. Java has seen some deep code-level changes and more modern approaches, requiring even more careful study and implementation. So learning the Head First way is more important than ever.

What's so special about this book?

If you've read a Head First book, you know what to expect--a visually rich format designed for the way your brain works. If you haven't, you're in for a treat. With this book, you'll learn Java through a multi-sensory experience that engages your mind rather than a text-heavy approach that puts you to sleep.

Table of Contents

  1. 1. Dive in A Quick Dip: Breaking the Surface
    1. The Way Java Works
    2. What you’ll do in Java
    3. A Very Brief History of Java
    4. Speed and Memory Usage
    5. Sharpen your pencil Answers
    6. Code structure in Java
    7. What goes in a source file?
    8. What goes in a class?
    9. What goes in a method?
    10. Anatomy of a class
    11. Writing a class with a main
    12. What can you say in the main method?
    13. Looping and looping and...
    14. Simple boolean tests
    15. There are no dumb Questions
    16. Example of a while loop
    17. Conditional branching
    18. Coding a Serious Business Application
    19. Monday Morning at Bob’s Java-Enabled House
    20. Phrase-O-Matic
    21. Code Magnets
    22. BE the compiler
    23. JavaCross 7.0
    24. Pool Puzzle
    25. Exercise Solutions
    26. puzzle answers
  2. 2. Classes and Objects: A Trip to Objectville
    1. Chair Wars
    2. (or How Objects Can Change Your Life)
    3. In Larry’s cube
    4. At Brad’s laptop at the cafe
    5. Larry thought he’d nailed it. He could almost feel the rolled steel of the Aeron beneath his...
    6. Back in Larry’s cube
    7. At Brad’s laptop at the beach
    8. Larry snuck in just moments ahead of Brad.
    9. Back in Larry’s cube
    10. At Brad’s laptop on his lawn chair at the Telluride Bluegrass Festival
    11. So, Brad the OO guy got the chair and desk, right?
    12. What about the Amoeba rotate()?
    13. The suspense is killing me. Who got the chair and desk?
    14. Brain Power
    15. When you design a class, think about the objects that will be created from that class t ype. Think about:
    16. What’s the difference between a class and an object?
    17. A class is not an object.
    18. Making your first object
    19. Making and testing Movie objects
    20. Quick! Get out of main!
    21. The Guessing Game
    22. Running the Guessing Game
    23. There are no Dumb Questions
    24. BE the compiler
    25. Code Magnets
    26. Pool Puzzle
    27. Exercise Solutions
    28. Puzzle Solutions
    29. Pool Puzzle
    30. Who am I?
  3. 3. Primitives And References: Know Your Variables
    1. Declaring a variable
    2. variables must have a type
    3. variables must have a name
    4. “I’d like a double mocha, no, make it an int.”
    5. Primitive Types
    6. You really don’t want to spill that...
    7. Back away from that keyword!
    8. Controlling your Dog object
    9. An object reference is just another variable value.
    10. The 3 steps of object declaration, creation and assignment
    11. There are no Dumb Questions
    12. Java Exposed
    13. Life on the garbage-collectible heap
    14. Life and death on the heap
    15. An array is like a tray of cups
    16. Arrays are objects too
    17. Make an array of Dogs
    18. Control your Dog
    19. What happens if the Dog is in a Dog array?
    20. A Dog example
    21. BE the compiler
    22. Code Magnets
    23. Pool Puzzle
    24. A Heap o’ Trouble
    25. The case of the pilfered references
    26. Exercise Solutions
    27. Puzzle Solutions
    28. The case of the pilfered references
  4. 4. methods use instance variables: How Objects Behave
    1. Remember: a class describes what an object knows and what an object does
    2. Can every object of that type have different method behavior?
    3. The size affects the bark
    4. You can send things to a method
    5. You can get things back from a method.
    6. You can send more than one thing to a method
    7. Calling a two-parameter method, and sending it two arguments.
    8. There are no Dumb Questions
    9. Reminder: Java cares about type!
    10. Cool things you can do with parameters and return types
    11. Encapsulation
    12. Do it or risk humiliation and ridicule.
    13. Hide the data
    14. Java Exposed
    15. Encapsulating the GoodDog class
    16. How do objects in an array behave?
    17. Declaring and initializing instance variables
    18. The difference between instance and local variables
    19. There are no Dumb Questions
    20. Comparing variables (primitives or references)
    21. BE the compiler
    22. Mixed Messages
    23. Pool Puzzle
    24. Fast Times in Stim-City
    25. Exercise Solutions
    26. Puzzle Solutions
  5. 5. Writing a Program: Extra-Strength Methods
    1. Let’s build a Battleship-style game: “Sink a Startup”
    2. First, a high-level design
    3. The “Simple Startup Game” a gentler introduction
    4. Developing a Class
    5. Brain Power
    6. SimpleStartup class
    7. Writing the method implementations
    8. let’s write the real method code now, and get this puppy working.
    9. Writing test code for the SimpleStartup class
    10. There are no Dumb Questions
    11. The checkYourself() method
    12. Just the new stuff
    13. There are no Dumb Questions
    14. Final code for SimpleStartup and SimpleStartupTester
    15. Prepcode for the SimpleStartupGame class
    16. The game’s main() method
    17. random() and getUserInput()
    18. One last class: GameHelper
    19. Let’s play
    20. What’s this? A bug ?
    21. More about for loops
    22. Regular (non-enhanced) for loops
    23. Trips through a loop
    24. Difference between for and while
    25. The enhanced for loop
    26. Casting primitives
    27. BE the JVM
    28. Code Magnets
    29. JavaCross
    30. Mixed Messages
    31. Exercise Solutions
    32. Puzzle Solutions
52.14.221.113