Head First Java

Head First Java

Head First Java

Head First Java

eBook

$50.99  $67.99 Save 25% Current price is $50.99, Original price is $67.99. You Save 25%.

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

What will you learn from this book?

Head First Java is a complete learning experience in Java and object-oriented programming. With this book, you'll learn the Java language with a unique method that goes beyond how-to manuals and helps you become a great programmer. Through puzzles, mysteries, and soul-searching interviews with famous Java objects, you'll quickly get up to speed on Java's fundamentals and advanced topics including lambdas, streams, generics, threading, networking, and the dreaded desktop GUI. If you have experience with another programming language, Head First Java will engage your brain with more modern approaches to coding--the sleeker, faster, and easier to read, write, and maintain Java of today.

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 Head First Java, you'll learn Java through a multisensory experience that engages your mind, rather than by means of a text-heavy approach that puts you to sleep.


Product Details

ISBN-13: 9781491910740
Publisher: O'Reilly Media, Incorporated
Publication date: 05/12/2022
Sold by: Barnes & Noble
Format: eBook
Pages: 754
Sales rank: 955,854
File size: 111 MB
Note: This product may take a few minutes to download.

About the Author

Kathy has been interested in learning theory since her days as a game designer for Virgin, MGM, and Amblin', and a teacher of New Media Authoring at UCLA. She was a master Java trainer for Sun Microsystems, and she founded JavaRanch.com (now CodeRanch.com), which won Jolt Cola Productivity awards in 2003 and 2004.

In 2015, she won the Electronic Frontier Foundation's Pioneer Award for her work creating skillful users and building sustainable communities. Kathy's recent focus has been on cutting-edge, movement science and skill acquisition coaching, known as ecological dynamics or Eco-D. Her work using Eco-D for training horses is ushering in a far, far more humane approach to horsemanship, causing delight for some (and sadly, consternation for others). Those fortunate (autonomous!) horses whose owners are using Kathy's approach are happier, healthier, and more athletic than their fellows who are traditionally trained.You can follow Kathy on Instagram @pantherflows


Before Bert was an author, he was a developer, specializing in old-school AI (mostly expert systems), real-time OSes, and complex scheduling systems. In 2003, Bert and Kathy wrote Head First Java and launched the Head First series. Since then, he's written more Java books and consulted with Sun Microsystems and Oracle on many of their Java certifications. He trains authors and editors to create books that teach well. Of the hundreds of authors he's trained, many have gone on to write best-selling books. Bert's a Go player, and in 2016 he watched in horror and fascination as AlphaGo trounced Lee Sedol. Recently he's been using Eco-D (ecological dynamics) to improve his golf game and to train his parrotlet Bokeh. You can email Bert at CodeRanch.com.


Trisha Gee is a Java Champion, published author, and leader of the Java developer advocacy team at JetBrains. She’s developed Java applications for companies of all sizes in the finance, manufacturing, and nonprofit industries and beyond. Trisha has expertise in Java high-performance systems, dabbles with open source development, and is a leader of the Sevilla Java User Group.

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<Dog>?; 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;
From the B&N Reads Blog

Customer Reviews