|
Book details / order |
HEAD FIRST JAVA, 2ND EDITION YOUR BRAIN ON JAVA - A LEARNER'S GUIDE |
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 its 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.
about the authors
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.
chapter 1 dive in a quick dip: breaking the surface
the way java works
what you’ll do in java
a very brief history of java
code structure in java
anatomy of a class
writing a class with a main
looping and looping and...
conditional branching
coding a serious business application
phrase-o-matic
chapter 2 classes and objects: a trip to objectville
chair wars: (or how objects can change your life)
making your first object
making and testing movie objects
quick! get out of main!
running the guessing game
chapter 3 primitives and references: know your variables
declaring a variable
“i’d like a double mocha, no, make it an int.”
you really don’t want to spill that...
back away from that keyword!
this table reserved
controlling your dog object
an object reference is just another variable value
an array is like a tray of cups
arrays are objects too
make an array of dogs
control your dog (with a reference variable)
a dog example
chapter 4 methods use instance variables: how objects behave
remember: a class describes what an object knows and what an object does
the size affects the bark
you can send things to a method
you can get things back from a method
you can send more than one thing to a method
java is pass-by-value. that means pass-by-copy
cool things you can do with parameters and return types
encapsulation
encapsulating the gooddog class
how do objects in an array behave?
declaring and initializing instance variables
the difference between instance and local variables
comparing variables (primitives or references)
chapter 5 writing a program: extra-strength methods
let’s build a battleship-style game: “sink a dot com”
first, a high-level design
the “simple dot com game” a gentler introduction
developing a class
the checkyourself() method
the game’s main() method
more about for loops
trips through a loop
the enhanced for loop
casting primitives
chapter 6 get to know the java api: using the java library
in our last chapter, we left you with the cliff-hanger. a bug
so what happened?
how do we fix it ?
option one is too clunky
option two is a little better, but still pretty clunky
wake up and smell the library
some things you can do with arraylist
comparing arraylist to a regular array
comparing arraylist to a regular array
let’s fix the dotcom code
new and improved dotcom class
let’s build the real game: “sink a dot com”
what needs to change?
who does what in the dotcombust game (and when)
prep code for the real dotcombust class
the final version of the dotcom class
super powerful boolean expressions
using the library (the java api)
how to play with the api
chapter 7 inheritance and polymorphism: better living in objectville
chair wars revisited...
let’s design the inheritance tree for an animal simulation program
using inheritance to avoid duplicating code in subclasses
do all animals eat the same way?
looking for more inheritance opportunities
designing an inheritance tree
when designing with inheritance, are you using or abusing?
keeping the contract: rules for overriding
overloading a method
chapter 8 interfaces and abstract classes: serious polymorphism
did we forget about something when we designed this?
interface to the rescue!
making and implementing the pet interface
chapter 9 constructors and garbage collection: life and death of an object
the stack and the heap: where things live
methods are stacked
what about local variables that are objects?
if local variables live on the stack, where do instance variables live?
the miracle of object creation
construct a duck
initializing the state of a new duck
using the constructor to initialize important duck statenot to imply that not all duck state is not unimportant.
make it easy to make a duck
doesn’t the compiler always make a no-arg constructor for you? no!
nanoreview: four things to remember about constructors
wait a minute... we never did talk about superclasses and inheritance and how that all fits in with constructors
the role of superclass constructors in an object’s life
making a hippo means making the animal and object parts too...
how do you invoke a superclass constructor?
can the child exist before the parents?
superclass constructors with arguments
invoking one overloaded constructor from another
now we know how an object is born, but how long does an object live?
what about reference variables?
chapter 10 numbers and statics: numbers matter
math methods: as close as you’ll ever get to a global method
the difference between regular (non-static) and static methods
what it means to have a class with static methods
static methods can’t use non-static (instance) variables!
static methods can’t use non-static methods, either!
static variable: value is the same for all instances of the class
initializing a static variable
static final variables are constants
final isn’t just for static variables...
math methods
wrapping a primitive
before java 5.0, you had to do the work...
autoboxing: blurring the line between primitive and object
autoboxing works almost everywhere
but wait! there’s more! wrappers have static utility methods too!
and now in reverse... turning a primitive number into a string
number formatting
formatting deconstructed...
the percent (%) says, “insert argument here” (and format it using these instructions)
the format string uses its own little language syntax
the format specifier
the only required specifier is for type
what happens if i have more than one argument?
so much for numbers, what about dates?
working with dates
moving backward and forward in time
getting an object that extends calendar
working with calendar objects
highlights of the calendar api
even more statics!... static imports
chapter 11 exception handling: risky behavior
let’s make a music machine
we’ll start with the basics
first we need a sequencer
the compiler needs to know that you know you’re calling a risky method
an exception is an object... of type exception
if it’s your code that catches the exception, then whose code throws it?
flow control in try/catch blocks
finally: for the things you want to do no matter what
did we mention that a method can throw more than one exception?
exceptions are polymorphic
multiple catch blocks must be ordered from smallest to biggest
you can’t put bigger baskets above smaller baskets
when you don’t want to handle an exception...
ducking (by declaring) only delays the inevitable
getting back to our music code...
making actual sound
your very first sound player app
making a midievent (song data)
midi message: the heart of a midievent
change a message
chapter 12 getting gui: a very graphic story
it all starts with a window
your first gui: a button on a frame
but nothing happens when i click it...
getting a user event
listeners, sources, and events
getting back to graphics...
make your own drawing widget
fun things to do in paintcomponent()
behind every good graphics reference is a graphics2d object
because life’s too short to paint the circle a solid color when there’s a gradient blend waiting for you
we can get an event. we can paint graphics. but can we paint graphics when we get an event?
gui layouts: putting more than one widget on a frame
let’s try it with two buttons
so now we need four widgets
and we need to get two events
inner class to the rescue!
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.
how to make an instance of an inner class
using an inner class for animation
listening for a non-gui event
an easier way to make messages / events
chapter 13 using swing: work on your swing
swing components
layout managers
how does the layout manager decide?
the big three layout managers: border, flow, and box
playing with swing components
making the beatbox
chapter 14 serialization and file i/o: saving objects
capture the beat
saving state
writing a serialized object to a file
data moves in streams from one place to another
what really happens to an object when it’s serialized?
but what exactly is an object’s state? what needs to be saved?
if you want your class to be serializable, implement serializable
deserialization: restoring an object
what happens during deserialization?
saving and restoring the game characters
writing a string to a text file
text file example: e-flashcards
quiz card builder (code outline)
the java.io.file class
reading from a text file
quiz card player (code outline)
parsing with string split()
version id: a big serialization gotcha
using the serialversionuid
saving a beatbox pattern
restoring a beatbox pattern
chapter 15 networking and threads: make a connection
real-time beat box chat
connecting, sending, and receiving
make a network socket connection
a tcp port is just a number. a 16-bit number that identifies a specific program on the server
to read data from a socket, use a bufferedreader
to write data to a socket, use a printwriter
the dailyadviceclient
dailyadviceclient code
writing a simple server
dailyadviceserver code
writing a chat client
java has multiple threads but only one thread class
what does it mean to have more than one call stack?
every thread needs a job to do. a method to put on the new thread stack
to make a job for your thread, implement the runnable interface
the thread scheduler
putting a thread to sleep
using sleep to make our program more predictable
making and starting two threads
what will happen?
um, yes. there is a dark side
the ryan and monica problem, in code
we need the makewithdrawal ( ) method to run as one atomic thing
using an object’s lock
the dreaded “lost update” problem
let’s run this code...
make the increment() method atomic. synchronize it!
the deadly side of synchronization
new and improved simplechatclient
the really really simple chat server
chapter 16 collections and generics: data structures
tracking song popularity on your jukebox
here’s what you have so far, without the sort:
but the arraylist class does not have a sort() method!
arraylist is not the only collection
you could use a treeset... or you could use the collections.sort() method
adding collections.sort() to the jukebox code
but now you need song objects, not just simple strings
changing the jukebox code to use songs instead of strings
it won’t compile!
generics means more type-safety
learning generics
using generic classes
using type parameters with arraylist
using generic methods
here’s where it gets weird...
revisiting the sort( ) method
in generics, “extends” means “extends or implements”
finally we know what’s wrong...
the new, improved, comparable song class
we can sort the list, but...
using a custom comparator
updating the jukebox to use a comparator
uh-oh. the sorting all works, but now we have duplicates...
we need a set instead of a list
the collection api (part of it)
using a hashset instead of arraylist
what makes two objects equal?
how a hashset checks for duplicates: hashcode() and equals()
the song class with overridden hashcode() and equals()
and if we want the set to stay sorted, we’ve got treeset
what you must know about treeset...
treeset elements must be comparable
we’ve seen lists and sets, now we’ll use a map
finally, back to generics
using polymorphic arguments and generics
but will it work with arraylist ?
what could happen if it were allowed...
wildcards to the rescue
alternate syntax for doing the same thing
chapter 17 package, jars and deployment: release your code
deploying your application
imagine this scenario...
separate source code and class files
put your java in a jar
running (executing) the jar
put your classes in packages!
preventing package name conflicts
compiling and running with packages
the -d flag is even cooler than we said
making an executable jar with packages
so where did the manifest file go?
java web start
the .jnlp file
chapter 18 remote deployment with rmi: distributed computing
method calls are always between two objects on the same heap
what if you want to invoke a method on an object running on another machine?
object a, running on little, wants to call a method on object b, running on big
but you can’t do that
the role of the ‘helpers’
java rmi gives you the client and service helper objects!
how does the client get the stub object?
how does the client get the stub class?
be sure each machine has the class files it needs
yeah, but who really uses rmi?
appendix final code kitchen
final beatbox client program
final beatbox server program
appendix 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)
appendix this isn’t goodbye.
Author : Kathy sierra, bert bates
Publication : Oreilly
Isbn : 9788173666025
Store book number : 105
NRS 1920.00
|
|
|
|
|
|
|
|
|
|