Synopses & Reviews
Between Moore's law and the notion of "Internet time," we're constantly being bombarded with more and more information--most of it in the form of disorganized data. Turning this information into useful knowledge is getting harder and harder to do, and it takes time that we just don't have. The current economic situation hasn't helped either. With money spread thin, who hasn't had to take on new tasks and learn new things? And slashed training budgets mean there's little to rely on for learning except books- but learning a complex new programming language like Java from a book is no simple task. Maybe your boss is giving you two weeks to come up to speed for a project, or maybe you're ready to take that next step up in your current job, or be a more viable candidate for a new job. Whatever the reason, the onus is on you to learn. All these factors make it more important than ever to have a way to learn--fast.
And that's what Head First Java does -- by exploiting the way your brain works, it compresses the time it takes to really learn. Why? Because its unique approach not only shows you what you need to know about Java syntax, it enables and encourages you to think like a Java programmer. Mastering object oriented programming requires a certain way of thinking, not just a certain way of writing code.
The latest research in cognitive science, neurobiology, and educational psychology shows that learning at the deeper levels takes a lot more than text on a page. Actively combining words and pictures not only helps in understanding the subject, but in remembering it. According to some studies, an engaging, entertaining, image-rich, conversational approach actually teaches the subject better. Head First Java puts these theories into practice with a vengeance. Chock full of mind stretching exercises, memorable analogies, and stories, humor and attitude that aren't just pasted-on distractions but that are used to drive home key points and make ideas come alive, the Head First approach is as effective as it is unique.
It takes a pretty unique person to have developed such an innovative way to Learn Java. Kathy Sierra has been interested in learning theory since her days as a game designer. More recently, she's been a master trainer for Sun Microsystems, teaching Sun's own instructors how to teach the latest Java technologies. She has been actively using the concepts in Head First Java to teach hundreds of trainers, developers and even non programmers. She is the founder of one of the largest Java community websites in the world, javaranch.com, and she is a member of the development team for the Sun Certified programmer exam. Bert Bates is also a long-time Java developer and trainer with extensive experience in learning theory. His background features a long stint in artificial intelligence with clients like the Weather Channel, A&E Network, Rockwell and Timken.
Is Head First Java right for you? That depends. Head First Java assumes you're a programmer or at least have experience with scripting languages. It assumes that you're smart, that you're creative and open to new ideas, and that you know you're just not the type of person who wants to learn the traditional way. Take a look at the sample pages, explore the background on brain-based learning, examine the table of contents, and see for yourself how Head First Java takes learning to a whole new level. See why Tim O'Reilly says, "This is the first really new approach to computer books that I've seen in many years. I think it's going to revolutionize how programming and other complex topics are taught."
Table of Content: 1) Dive In (a quick dip into Java) 2) Welcome to Objectville (intro to OO) 3) Know your Variables (understanding Java types: primitives, object references, pass-by-value) 4) How objects behave (instance variables and methods) 5) Extra-strength methods (writing more complex code) 6) Using the Java Library (solving problems with the API) 7) Better Living in Objectville (inheritance, OO design, abstract classes) 8) Serious Polymorphism (interfaces, more OO design, polymorphism) 9) Life and Death of an object (constructors and memory management / garbage collection) 10) Do the Math (static methods and variables, Math methods, Wrappers, and number formatting) 11) Risky Behavior (handling exceptions) 12) A very graphic story (GUI intro, inner classes, event handling) 13) Work on your swing (more GUI, layout managers and Swing components) 14) Saving objects (object serialization and file I/O) 15) Make a connection (networking: sockets and server sockets) 16) Release your Code (deployment: code organization, packages, executable JARs, and Java Web Start) 17) Distributed Code (deployment via RMI and Servlets)
Learning a complex new language is no easy task especially when its an object-oriented computer programming language like Java. This resource combines puzzles, strong visuals, mysteries, and soul-searching interviews to offer a complete introduction to object-oriented programming and Java.
Learning a complex new language is no easy task especially when it s an object-oriented computer programming language like Java. You might think the problem is your brain. It seems to have a mind of its own, a mind that doesn't always want to take in the dry, technical stuff you're forced to study.
The fact is your brain craves novelty. It's constantly searching, scanning, waiting for something unusual to happen. After all, that's the way it was built to help you stay alive. It takes all the routine, ordinary, dull stuff and filters it to the background so it won't interfere with your brain's real work--recording things that matter. How does your brain know what matters? It's like the creators of the Head First approach say, suppose you're out for a hike and a tiger jumps in front of you, what happens in your brain? Neurons fire. Emotions crank up. Chemicals surge.
That's how your brain knows.
And that's how your brain will learn Java. Head First Java 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, including threads, network sockets, and distributed programming with RMI. And the new. second edition focuses on Java 5.0, the latest version of the Java language and development platform. Because Java 5.0 is a major update to the platform, with deep, code-level changes, even more careful study and implementation is required. So learning the Head First way is more important than ever.
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. You'll see why people say it's unlike any other Java book you've ever read.
By exploiting how your brain works, Head First Java compresses the time it takes to learn and retain--complex information. Its unique approach not only shows you what you need to know about Java syntax, it teaches you to think like a Java programmer. If you want to be bored, buy some other book. But if you want to understand Java, this book's for you.
"Head First Java" engages readers on many levels, bringing the latest learning theories and research together to create not just a book to read, but a multi-sensory learning experience.
About the Author
Kathy Sierra has been interested in learning theory since her days as a game developer (Virgin, MGM, Amblin'). More recently, she's been a master trainer for Sun Microsystems, teaching Sun's Java instructors how to teach the latest technologies to customers, and a lead developer of several Sun certification exams. Along with her partner Bert Bates, Kathy created the Head First series. She's also the original founder of the Software Development/Jolt Productivity Award-winning javaranch.com, the largest (and friendliest) all-volunteer Java community.
Bert Bates is a 20-year software developer, a Java instructor, and a co-developer of Sun's upcoming EJB exam (Sun Certified Business Component Developer). His background features a long stint in artificial intelligence, with clients like the Weather Channel, A&E Network, Rockwell, and Timken.
Table of Contents
; What they're saying about Head First; Praise for Head First Java; Praise for other Head First books co-authored by Kathy and Bert; Creators of the Head First series; How to Use This Book: Intro; Who is this book for?; We know what you're thinking; And we know what your brain is thinking; Metacognition: thinking about thinking; Here's what WE did; Here's what YOU can do to bend your brain into submission; What you need for this book; Last-minute things you need to know; Technical Editors; Other people to : credit; Just when you thought there wouldn't be any more acknowledgementsThe large number of acknowledgements is because we're testing the theory that everyone mentioned in a book acknowledgement will buy at least one copy, probably more, what with relatives and everything. If you'd like to be in the acknowledgement of our next book, and you have a large family, write to us.; Chapter 1: Dive in A Quick Dip: Breaking the Surface; 1.1 The Way Java Works; 1.2 What you'll do in Java; 1.3 A very brief history of Java; 1.4 Code structure in Java; 1.5 Anatomy of a class; 1.6 Writing a class with a main; 1.7 Looping and looping and...; 1.8 Conditional branching; 1.9 Coding a Serious Business Application; 1.10 Phrase-O-Matic; Chapter 2: Classes and Objects: A Trip to Objectville; 2.1 Chair Wars: (or How Objects Can Change Your Life); 2.2 Making your first object; 2.3 Making and testing Movie objects; 2.4 Quick! Get out of main!; 2.5 Running the Guessing Game; Chapter 3: Primitives and References: Know Your Variables; 3.1 Declaring a variable; 3.2 "I'd like a double mocha, no, make it an int."; 3.3 You really don't want to spill that...; 3.4 Back away from that keyword!; 3.5 This table reserved; 3.6 Controlling your Dog object; 3.7 An object reference is just another variable value; 3.8 An array is like a tray of cups; 3.9 Arrays are objects too; 3.10 Make an array of Dogs; 3.11 Control your Dog (with a reference variable); 3.12 A Dog example; Chapter 4: Methods Use Instance Variables: How Objects Behave; 4.1 Remember: a class describes what an object knows and what an object does; 4.2 The size affects the bark; 4.3 You can send things to a method; 4.4 You can get things back from a method; 4.5 You can send more than one thing to a method; 4.6 Java is pass-by-value. That means pass-by-copy; 4.7 Cool things you can do with parameters and return types; 4.8 Encapsulation; 4.9 Encapsulating the GoodDog class; 4.10 How do objects in an array behave?; 4.11 Declaring and initializing instance variables; 4.12 The difference between instance and local variables; 4.13 Comparing variables (primitives or references); Chapter 5: Writing a Program: Extra-Strength Methods; 5.1 Let's build a Battleship-style game: "Sink a Dot Com"; 5.2 First, a high-level design; 5.3 The "Simple Dot Com Game" a gentler introduction; 5.4 Developing a Class; 5.5 The checkYourself() method; 5.6 The game's main() method; 5.7 More about for loops; 5.8 Trips through a loop; 5.9 The enhanced for loop; 5.10 Casting primitives; Chapter 6: Get to Know the Java API: Using the Java Library; 6.1 In our last chapter, we left you with the cliff-hanger. A bug; 6.2 So what happened?; 6.3 How do we fix it ?; 6.4 Option one is too clunky; 6.5 Option two is a little better, but still pretty clunky; 6.6 Wake up and smell the library; 6.7 Some things you can do with ArrayList; 6.8 Comparing ArrayList to a regular array; 6.9 Comparing ArrayList to a regular array; 6.10 Let's fix the DotCom code; 6.11 New and improved DotCom class; 6.12 Let's build the REAL game: "Sink a Dot Com"; 6.13 What needs to change?; 6.14 Who does what in the DotComBust game (and when); 6.15 Prep code for the real DotComBust class; 6.16 The final version of the DotCom class; 6.17 Super Powerful Boolean Expressions; 6.18 Using the Library (the Java API); 6.19 How to play with the API; Chapter 7: Inheritance and Polymorphism: Better Living in Objectville; 7.1 Chair Wars Revisited...; 7.2 Let's design the inheritance tree for an Animal simulation program; 7.3 Using inheritance to avoid duplicating code in subclasses; 7.4 Do all animals eat the same way?; 7.5 Looking for more inheritance opportunities; 7.6 Designing an Inheritance Tree; 7.7 When designing with inheritance, are you using or abusing?; 7.8 Keeping the contract: rules for overriding; 7.9 Overloading a method; Chapter 8: Interfaces and Abstract Classes: Serious Polymorphism; 8.1 Did we forget about something when we designed this?; 8.2 Interface to the rescue!; 8.3 Making and Implementing the Pet interface; Chapter 9: Constructors and Garbage Collection: Life and Death of an Object; 9.1 The Stack and the Heap: where things live; 9.2 Methods are stacked; 9.3 What about local variables that are objects?; 9.4 If local variables live on the stack, where do instance variables live?; 9.5 The miracle of object creation; 9.6 Construct a Duck; 9.7 Initializing the state of a new Duck; 9.8 Using the constructor to initialize important Duck stateNot to imply that not all Duck state is not unimportant.; 9.9 Make it easy to make a Duck; 9.10 Doesn't the compiler always make a no-arg constructor for you? No!; 9.11 Nanoreview: four things to remember about constructors; 9.12 Wait a minute... we never DID talk about superclasses and inheritance and how that all fits in with constructors; 9.13 The role of superclass constructors in an object's life; 9.14 Making a Hippo means making the Animal and Object parts too...; 9.15 How do you invoke a superclass constructor?; 9.16 Can the child exist before the parents?; 9.17 Superclass constructors with arguments; 9.18 Invoking one overloaded constructor from another; 9.19 Now we know how an object is born, but how long does an object live?; 9.20 What about reference variables?; Chapter 10: Numbers and Statics: Numbers Matter; 10.1 MATH methods: as close as you'll ever get to a global method; 10.2 The difference between regular (non-static) and static methods; 10.3 What it means to have a class with static methods; 10.4 Static methods can't use non-static (instance) variables!; 10.5 Static methods can't use non-static methods, either!; 10.6 Static variable: value is the same for ALL instances of the class; 10.7 Initializing a static variable; 10.8 static final variables are constants; 10.9 final isn't just for static variables...; 10.10 Math methods; 10.11 Wrapping a primitive; 10.12 Before Java 5.0, YOU had to do the work...; 10.13 Autoboxing: blurring the line between primitive and object; 10.14 Autoboxing works almost everywhere; 10.15 But wait! There's more! Wrappers have static utility methods too!; 10.16 And now in reverse... turning a primitive number into a String; 10.17 Number formatting; 10.18 Formatting deconstructed...; 10.19 The percent (%) says, "insert argument here" (and format it using these instructions); 10.20 The format String uses its own little language syntax; 10.21 The format specifier; 10.22 The only required specifier is for TYPE; 10.23 What happens if I have more than one argument?; 10.24 So much for numbers, what about dates?; 10.25 Working with Dates; 10.26 Moving backward and forward in time; 10.27 Getting an object that extends Calendar; 10.28 Working with Calendar objects; 10.29 Highlights of the Calendar API; 10.30 Even more Statics!... static imports; Chapter 11: Exception Handling: Risky Behavior; 11.1 Let's make a Music Machine; 11.2 We'll start with the basics; 11.3 First we need a Sequencer; 11.4 The compiler needs to know that YOU know you're calling a risky method; 11.5 An exception is an object... of type Exception; 11.6 If it's your code that catches the exception, then whose code throws it?; 11.7 Flow control in try/catch blocks; 11.8 Finally: for the things you want to do no matter what; 11.9 Did we mention that a method can throw more than one exception?; 11.10 Exceptions are polymorphic; 11.11 Multiple catch blocks must be ordered from smallest to biggest; 11.12 You can't put bigger baskets above smaller baskets; 11.13 When you don't want to handle an exception...; 11.14 Ducking (by declaring) only delays the inevitable; 11.15 Getting back to our music code...; 11.16 Making actual sound; 11.17 Your very first sound player app; 11.18 Making a MidiEvent (song data); 11.19 MIDI message: the heart of a MidiEvent; 11.20 Change a message; Chapter 12: Getting GUI: A Very Graphic Story; 12.1 It all starts with a window; 12.2 Your first GUI: a button on a frame; 12.3 But nothing happens when I click it...; 12.4 Getting a user event; 12.5 Listeners, Sources, and Events; 12.6 Getting back to graphics...; 12.7 Make your own drawing widget; 12.8 Fun things to do in paintComponent(); 12.9 Behind every good Graphics reference is a Graphics2D object; 12.10 Because life's too short to paint the circle a solid color when there's a gradient blend waiting for you; 12.11 We can get an event. We can paint graphics. But can we paint graphics when we get an event?; 12.12 GUI layouts: putting more than one widget on a frame; 12.13 Let's try it with TWO buttons; 12.14 So now we need FOUR widgets; 12.15 And we need to get TWO events; 12.16 Inner class to the rescue!; 12.17 An inner class instance must be tied to an outer class instanceThere's an exception to this, for a very special case--an inner class defined within a static method. But we're not going there, and you might go your entire Java life without ever encountering one of these.; 12.18 How to make an instance of an inner class; 12.19 Using an inner class for animation; 12.20 Listening for a non-GUI event; 12.21 An easier way to make messages / events; Chapter 13: Using Swing: Work on Your Swing; 13.1 Swing components; 13.2 Layout Managers; 13.3 How does the layout manager decide?; 13.4 The Big Three layout managers: border, flow, and box; 13.5 Playing with Swing components; 13.6 Making the BeatBox; Chapter 14: Serialization and File I/O: Saving Objects; 14.1 Capture the Beat; 14.2 Saving State; 14.3 Writing a serialized object to a file; 14.4 Data moves in streams from one place to another; 14.5 What really happens to an object when it's serialized?; 14.6 But what exactly IS an object's state? What needs to be saved?; 14.7 If you want your class to be serializable, implement Serializable; 14.8 Deserialization: restoring an object; 14.9 What happens during deserialization?; 14.10 Saving and restoring the game characters; 14.11 Writing a String to a Text File; 14.12 Text File Example: e-Flashcards; 14.13 Quiz Card Builder (code outline); 14.14 The java.io.File class; 14.15 Reading from a Text File; 14.16 Quiz Card Player (code outline); 14.17 Parsing with String split(); 14.18 Version ID: A Big Serialization Gotcha; 14.19 Using the serialVersionUID; 14.20 Saving a BeatBox pattern; 14.21 Restoring a BeatBox pattern; Chapter 15: Networking and Threads: Make a Connection; 15.1 Real-time Beat Box Chat; 15.2 Connecting, Sending, and Receiving; 15.3 Make a network Socket connection; 15.4 A TCP port is just a number. A 16-bit number that identifies a specific program on the server; 15.5 To read data from a Socket, use a BufferedReader; 15.6 To write data to a Socket, use a PrintWriter; 15.7 The DailyAdviceClient; 15.8 DailyAdviceClient code; 15.9 Writing a simple server; 15.10 DailyAdviceServer code; 15.11 Writing a Chat Client; 15.12 Java has multiple threads but only one Thread class; 15.13 What does it mean to have more than one call stack?; 15.14 Every Thread needs a job to do. A method to put on the new thread stack; 15.15 To make a job for your thread, implement the Runnable interface; 15.16 The Thread Scheduler; 15.17 Putting a thread to sleep; 15.18 Using sleep to make our program more predictable; 15.19 Making and starting two threads; 15.20 What will happen?; 15.21 Um, yes. There IS a dark side; 15.22 The Ryan and Monica problem, in code; 15.23 We need the makeWithdrawal ( ) method to run as one atomic thing; 15.24 Using an object's lock; 15.25 The dreaded "Lost Update" problem; 15.26 Let's run this code...; 15.27 Make the increment() method atomic. Synchronize it!; 15.28 The deadly side of synchronization; 15.29 New and improved SimpleChatClient; 15.30 The really really simple Chat Server; Chapter 16: Collections and Generics: Data structures; 16.1 Tracking song popularity on your jukebox; 16.2 Here's what you have so far, without the sort:; 16.3 But the ArrayList class does NOT have a sort() method!; 16.4 ArrayList is not the only collection; 16.5 You could use a TreeSet... Or you could use the Collections.sort() method; 16.6 Adding Collections.sort() to the Jukebox code; 16.7 But now you need Song objects, not just simple Strings; 16.8 Changing the Jukebox code to use Songs instead of Strings; 16.9 It won't compile!; 16.10 Generics means more type-safety; 16.11 Learning generics; 16.12 Using generic CLASSES; 16.13 Using type parameters with ArrayList; 16.14 Using generic METHODS; 16.15 Here's where it gets weird...; 16.16 Revisiting the sort( ) method; 16.17 In generics, "extends" means "extends or implements"; 16.18 Finally we know what's wrong...; 16.19 The new, improved, comparable Song class; 16.20 We can sort the list, but...; 16.21 Using a custom Comparator; 16.22 Updating the Jukebox to use a Comparator; 16.23 Uh-oh. The sorting all works, but now we have duplicates...; 16.24 We need a Set instead of a List; 16.25 The Collection API (part of it); 16.26 Using a HashSet instead of ArrayList; 16.27 What makes two objects equal?; 16.28 How a HashSet checks for duplicates: hashCode() and equals(); 16.29 The Song class with overridden hashCode() and equals(); 16.30 And if we want the set to stay sorted, we've got TreeSet; 16.31 What you MUST know about TreeSet...; 16.32 TreeSet elements MUST be comparable; 16.33 We've seen Lists and Sets, now we'll use a Map; 16.34 Finally, back to generics; 16.35 Using polymorphic arguments and generics; 16.36 But will it work with ArrayList ?; 16.37 What could happen if it were allowed...; 16.38 Wildcards to the rescue; 16.39 Alternate syntax for doing the same thing; Chapter 17: Package, Jars and Deployment: Release Your Code; 17.1 Deploying your application; 17.2 Imagine this scenario...; 17.3 Separate source code and class files; 17.4 Put your Java in a JAR; 17.5 Running (executing) the JAR; 17.6 Put your classes in packages!; 17.7 Preventing package name conflicts; 17.8 Compiling and running with packages; 17.9 The -d flag is even cooler than we said; 17.10 Making an executable JAR with packages; 17.11 So where did the manifest file go?; 17.12 Java Web Start; 17.13 The .jnlp file; Chapter 18: Remote Deployment with RMI: Distributed Computing; 18.1 Method calls are always between two objects on the same heap; 18.2 What if you want to invoke a method on an object running on another machine?; 18.3 Object A, running on Little, wants to call a method on Object B, running on Big; 18.4 But you can't do that; 18.5 The role of the 'helpers'; 18.6 Java RMI gives you the client and service helper objects!; 18.7 How does the client get the stub object?; 18.8 How does the client get the stub class?; 18.9 Be sure each machine has the class files it needs; 18.10 Yeah, but who really uses RMI?; Final Code Kitchen; Final BeatBox client program; Final BeatBox server program; The Top Ten Topics that almost made it into the Real Book...; #10 Bit Manipulation; #9 Immutability; #8 Assertions; #7 Block Scope; #6 Linked Invocations; #5 Anonymous and Static Nested Classes; #4 Access Levels and Access Modifiers (Who Sees What); #3 String and StringBuffer/StringBuilder Methods; #2 Multidimensional Arrays; And the number one topic that didn't quite make it in...; #1 Enumerations (also called Enumerated Types or Enums); This isn't goodbye;