Head first Java: [your brain on Java - a learner's guide]
Gespeichert in:
Hauptverfasser: | , |
---|---|
Format: | Buch |
Sprache: | English |
Veröffentlicht: |
Beijing [u.a.]
O'Reilly
2005
|
Ausgabe: | 2. ed. |
Schlagworte: | |
Online-Zugang: | Inhaltsverzeichnis Inhaltsverzeichnis |
Beschreibung: | XXXII, 688 S. Ill. |
ISBN: | 0596009208 9780596009205 |
Internformat
MARC
LEADER | 00000nam a2200000 c 4500 | ||
---|---|---|---|
001 | BV020874540 | ||
003 | DE-604 | ||
005 | 20191023 | ||
007 | t | ||
008 | 051117s2005 gw a||| |||| 00||| eng d | ||
020 | |a 0596009208 |9 0-596-00920-8 | ||
020 | |a 9780596009205 |9 978-0-596-00920-5 | ||
035 | |a (OCoLC)254510658 | ||
035 | |a (DE-599)BVBBV020874540 | ||
040 | |a DE-604 |b ger |e rakddb | ||
041 | 0 | |a eng | |
044 | |a gw |c DE | ||
049 | |a DE-573 |a DE-Aug4 |a DE-473 |a DE-1051 |a DE-526 |a DE-384 |a DE-188 |a DE-523 |a DE-83 |a DE-898 | ||
050 | 0 | |a QA76.73.J38 | |
082 | 0 | |a 005.133 | |
084 | |a ST 250 |0 (DE-625)143626: |2 rvk | ||
100 | 1 | |a Sierra, Kathy |d ca. 20./21. Jahrhundert |e Verfasser |0 (DE-588)119774696X |4 aut | |
245 | 1 | 0 | |a Head first Java |b [your brain on Java - a learner's guide] |c Kathy Sierra ; Bert Bates |
250 | |a 2. ed. | ||
264 | 1 | |a Beijing [u.a.] |b O'Reilly |c 2005 | |
300 | |a XXXII, 688 S. |b Ill. | ||
336 | |b txt |2 rdacontent | ||
337 | |b n |2 rdamedia | ||
338 | |b nc |2 rdacarrier | ||
650 | 4 | |a Java 2 Standard Edition 5.0 - Objektorientierte Programmierung | |
650 | 4 | |a Java (Computer program language) | |
650 | 0 | 7 | |a Java |g Programmiersprache |0 (DE-588)4401313-9 |2 gnd |9 rswk-swf |
650 | 0 | 7 | |a Java 2 Standard Edition 5.0 |0 (DE-588)4799436-8 |2 gnd |9 rswk-swf |
650 | 0 | 7 | |a Objektorientierte Programmierung |0 (DE-588)4233947-9 |2 gnd |9 rswk-swf |
689 | 0 | 0 | |a Java |g Programmiersprache |0 (DE-588)4401313-9 |D s |
689 | 0 | 1 | |a Objektorientierte Programmierung |0 (DE-588)4233947-9 |D s |
689 | 0 | |5 DE-604 | |
689 | 1 | 0 | |a Java 2 Standard Edition 5.0 |0 (DE-588)4799436-8 |D s |
689 | 1 | 1 | |a Objektorientierte Programmierung |0 (DE-588)4233947-9 |D s |
689 | 1 | |5 DE-188 | |
700 | 1 | |a Bates, Bert |e Verfasser |4 aut | |
856 | 4 | |u http://www.ulb.tu-darmstadt.de/tocs/126586330.pdf |3 Inhaltsverzeichnis | |
856 | 4 | 2 | |m HEBIS Datenaustausch Darmstadt |q application/pdf |u http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=014196236&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |3 Inhaltsverzeichnis |
999 | |a oai:aleph.bib-bvb.de:BVB01-014196236 |
Datensatz im Suchindex
_version_ | 1804134602735878144 |
---|---|
adam_text | HEAD FIRST JAVA* SECOND EDITION WOULDN T IT BE DREAMY IF THERE WAS A
JAVA BOOK THAT WAS MORE STIMULATING THAN WAITING IN LINE AT THE DAAV TO
RENEW YOUR DRIVER S LICENSE? IT S PROBABLY JUST A FANTASY... KATHY
SIERRA BERT BATES BEIJING * CAMBRIDGE * KOLN O REILLY* PARIS *
SEBASTOPOL * TAIPEI * TOKYO 1 BREAKING THE SURFACE JAVA TAKES YOU TO NEW
PLACES. FROM ITS HUMBLE RELEASE TO THE PUBLIC AS THE (WIMPY) VERSION
1.02, JAVA SEDUCED PROGRAMMERS WITH ITS FRIENDLY SYNTAX, OBJECT-ORIENTED
FEATURES, MEMORY MANAGEMENT, AND BEST OF ALL*THE PROMISE OF PORTABILITY.
WE LL TAKE A QUICK DIP AND WRITE SOME CODE, COMPILE IT, AND RUN IT.
WE RE TALKING SYNTAX, LOOPS, BRANCHING, AND WHAT MAKES JAVA SO COOL.
DIVE IN. VIRTUAL MACHINES METHOD PARTY() 0 ALOAD _0 1 INVOKESPE- CIAL#1
JAVA.LANG.OBJECT() 4 RETURN BYTECODE THE WAY JAVA WORKS CODE STRUCTURE
IN JAVA ANATOMY OF A CLASS THE MAINQ METHOD LOOPING CONDITIONAL
BRANCHING (IF TESTS) CODING THE 99 BOTTLES OF BEER APP PHRASE-O-MATIC
FIRESIDE CHAT: COMPILER VS. JVM EXERCISES AND PUZZLES 2 7 8 9 11 13 14
16 18 20 2 A TRIP TO OBJECTVILLE I WAS TOLD THERE WOULD BE OBJECTS. IN
CHAPTER 1,WE PUT ALL OF OUR CODE IN THE MAIN() METHOD. THAT S NOT
EXACTLY OBJECT-ORIENTED. SO NOW WE VE GOT TO LEAVE THAT PROCEDURAL WORLD
BEHIND AND START MAKING SOME OBJECTS OF OUR OWN. WE LL LOOK AT WHAT
MAKES OBJECT-ORIENTED (00) DEVELOPMENT IN JAVA SO MUCH FUN. WE LL LOOK
AT THE DIFFERENCE BETWEEN A CLASS AND AN OBJECT. WE LL LOOK AT HOW
OBJECTS CAN IMPROVE YOUR LIFE. MANY OBJECTS CHAIR WARS (BRAD THE OO GUY
VS. LARRY THE PROCEDURAL GUY) INHERITANCE (AN INTRODUCTION) OVERRIDING
METHODS (AN INTRODUCTION) WHAT S IN A CLASS? (METHODS, INSTANCE
VARIABLES) MAKING YOUR FIRST OBJECT USING MAINQ GUESSING GAME CODE
EXERCISES AND PUZZLES 28 31 32 34 36 38 39 42 R 3 KNOW YOUR VARIABLES
VARIABLES COME IN TWO FLAVORS: PRIMITIVE AND REFERENCE. THERE S GOTTA BE
MORE TO LIFE THAN INTEGERS. STRINGS, AND ARRAYS. WHAT IF YOU HAVE A
PETOWNER OBJECT WITH A DOG INSTANCE VARIABLE? OR A CAR WITH AN ENGINE?
IN THIS CHAPTER WE LL UNWRAP THE MYSTERIES OF JAVA TYPES AND LOOKAT WHAT
YOU CAN DECLARE AS A VARIABLE, WHAT YOU CAN PUT IN A VARIABLE, AND WHAT
YOU CAN DO WITH A VARIABLE. AND WE LL FINALLY SEE WHAT LIFE IS TRULY
LIKE ON THE GARBAGE-COLLECTIBLE HEAP. DECLARING A VARIABLE (JAVA CARES
ABOUT TYPE) PRIMITIVE TYPES ( I D LIKE A DOUBLE WITH EXTRA FOAM,
PLEASE ) JAVA KEYWORDS REFERENCE VARIABLES (REMOTE CONTROL TO AN OBJECT)
OBJECT DECLARATION AND ASSIGNMENT OBJECTS ON THE GARBAGE-COLLECTIBLE
HEAP ARRAYS (A FIRST LOOK) EXERCISES AND PUZZLES 50 51 53 54 55 57 59 63
DOG REFERENCE 4 HOW OBJECTS BEHAVE STATE AFFECTS BEHAVIOR, BEHAVIOR
AFFECTS STATE, WE KNOW THAT OBJECTS HAVE STATE AND BEHAVIOR, REPRESENTED
BY INSTANCE VARIABLES AND METHODS. NOW WE LL LOOK AT HOW STATE AND
BEHAVIOR ARE RELATED. AN OBJECT S BEHAVIOR USES AN OBJECT S UNIQUE
STATE. IN OTHER WORDS, METHODS USE INSTANCE VARIABLE VALUES. LIKE, IF
DOG WEIGHT IS LESS THAN 14 POUNDS, MAKE YIPPY SOUND, ELSE... LET S GO
CHANGE SOME STATE! PASS-BY-VALUE MEANS PASS-BY-COPY INT F OO . GO (X) ;
METHODS USE OBJECT STATE (BARK DIFFERENT) METHOD ARGUMENTS AND RETURN
TYPES PASS-BY-VALUE (THE VARIABLE IS ALWAYS COPIED) GETTERS AND SETTERS
ENCAPSULATION (DO IT OR RISK HUMILIATION) USING REFERENCES IN AN ARRAY
EXERCISES AND PUZZLES 73 74 77 79 80 83 VOID GO(INT Z) { } XI 5 TO* A B
C D E F G G 5 !TS.C ASL M ME.C EXTRA-STRENGTH METHODS LET S PUT SOME
MUSCLE IN OUR METHODS. YOU DABBLED WITH VARIABLES, PLAYED WITH A FEW
OBJECTS, AND WROTE A LITTLE CODE. BUT YOU NEED MORE TOOLS. LIKE
OPERATORS. AND LOOPS. MIGHT BE USEFUL TO GENERATE RANDOM NUMBERS. AND
TURN A STRING INTO AN INT, YEAH, THAT WOULD BE COOL. AND WHY DON T WE
LEARN IT ALL BY BUILDING SOMETHING REAL, TO SEE WHAT IT S LIKE TO WRITE
(AND TEST) A PROGRAM FROM SCRATCH. MAYB E A GAME, LIKE SINK A DOT COM
(SIMILAR TO BATTLESHIP). BUILDING THE SINK A DOT COM GAME 96 STARTING
WITH THE SIMPLE DOT COM GAME (A SIMPLER VERSION) 98 WRITING PREPCODE
(PSEUDOCODE FOR THE GAME) 100 TEST CODE FOR SIMPLE DOT COM 102 CODING
THE SIMPLE DOT COM GAME 103 FINAL CODE FOR SIMPLE DOT COM 106 GENERATING
RANDOM NUMBERS WITH MATH.RANDOM() 111 READY-BAKE CODE FOR GETTING USER
INPUT FROM THE COMMAND-LINE 112 LOOPING WITH FOR LOOPS 114 CASTING
PRIMITIVES FROM A LARGE SIZE TO A SMALLER SIZE 117 CONVERTING A STRING
TO AN INT WITH INTEGER.PARSELNTO 117 EXERCISES AND PUZZLES 118 6 USING
THE JAVA LIBRARY JAVA SHIPS WITH HUNDREDS OF PRE-BUILT CLASSES, YOU
DON T HAVE TO REINVENT THE WHEEL IF YOU KNOW HOW TO FIND WHAT YOU NEED
FROM THE JAVA LIBRARY, COMMONLY KNOWN AS THE JAVA API. YOU VE GOT BETTER
THINGS TO DO. IF YOU RE GOING TO WRITE CODE, YOU MIGHT AS WELL WRITE
ONLY THE PARTS THAT ARE CUSTOM FOR YOUR APPLICATION.THE CORE JAVA
LIBRARY IS A GIANT PILE OF CLASSES JUST WAITING FOR YOU TO USE LIKE
BUILDING BLOCKS. GOOD TO KNOW THERE S AN ARRAY LIST IN THE JAVA. UTIL
PACKAGE. BUT BY MYSELF, HOW WOULD I HAVE FIGURED THAT OUT? - JULIA, 31,
HAND MODEL ANALYING THE BUG IN THE SIMPLE DOT COM GAME ARRAY LIST
(TAKING ADVANTAGE OF THE JAVA API) FIXING THE DOTCOM CLASS CODE BUILDING
THE REAL GAME (SINK A DOT COM) PREPCODE FOR THE REAL GAME CODE FOR THE
REAL GAME BOOLEAN EXPRESSIONS USING THE LIBRARY (JAVA API) USING
PACKAGES (IMPORT STATEMENTS, FULLY-QUALIFIED NAMES) USING THE HTML API
DOCS AND REFERENCE BOOKS EXERCISES AND PUZZLES 126 132 138 140 144 146
151 154 155 158 161 XII 7 BETTER LIVING IN OBJECTVILLE PLAN YOUR
PROGRAMS WITH THE FUTURE IN MIND, WHAT IF YOU COULD WRITE CODE THAT
SOMEONE ELSE COULD EXTEND, EASILY? WHAT IF YOU COULD WRITE CODE THAT WAS
FLEXIBLE, FOR THOSE PESKY LAST-MINUTE SPEC CHANGES? WHEN YOU GET ON THE
POLYMORPHISM PLAN, YOU LL LEARN THE 5 STEPS TO BETTER CLASS DESIGN, THE
3 TRICKS TO POLYMORPHISM, THE 8 WAYS TO MAKE FLEXIBLE CODE, AND IF YOU
ACT NOW*A BONUS LESSON ON THE 4 TIPS FOR EXPLOITING INHERITANCE.
UNDERSTANDING INHERITANCE (SUPERCLASS AND SUBCLASS RELATIONSHIPS) 168
DESIGNING AN INHERITANCE TREE (THE ANIMAL SIMULATION) 170 AVOIDING
DUPLICATE CODE (USING INHERITANCE) 171 OVERRIDING METHODS 172 IS-A AND
HAS-A (BATHTUB GIRL) 17 7 WHAT DO YOU INHERIT FROM YOUR SUPERCLASS? 180
WHAT DOES INHERITANCE REALLY BUY YOU? 182 POLYMORPHISM (USING A
SUPERTYPE REFERENCE TO A SUBCLASS OBJECT) 183 RULES FOR OVERRIDING
(DON T TOUCH THOSE ARGUMENTS AND RETURN TYPES!) 190 METHOD OVERLOADING
(NOTHING MORE THAN METHOD NAME RE-USE) 191 EXERCISES AND PUZZLES 192
SERIOUS POLYMORPHISM INHERITANCE IS JUST THE BEGINNING, TO EXPLOIT
POLYMORPHISM, WE NEED INTERFACES. WE NEED TO GO BEYOND SIMPLE
INHERITANCE TO FLEXIBILITY YOU CAN GET ONLY BY DESIGNING AND CODING TO
INTERFACES. WHAT S AN INTERFACE? A 100% ABSTRACT CLASS. WHAT S AN
ABSTRACT CLASS? A CLASS THAT CAN T BE INSTANTIATED. WHAT S THAT GOOD
FOR? READ THE CHAPTER... OBJECT O = AL.GET(ID); DOG D = (DOG) O;
D.BARK(); SOME CLASSES JUST SHOULD NOT BE INSTANTIATED ABSTRACT CLASSES
(CAN T BE INSTANTIATED) ABSTRACT METHODS (MUST BE IMPLEMENTED)
POLYMORPHISM IN ACTION CLASS OBJECT (THE ULTIMATE SUPERCLASS OF
EVERYTHING) TAKING OBJECTS OUT OF AN ARRAYLIST (THEY COME OUT AS TYPE
OBJECT) COMPILER CHECKS THE REFERENCE TYPE (BEFORE LETTING YOU CALL A
MEDIOD) GET IN TOUCH WITH YOUR INNER OBJECT POLYMORPHIC REFERENCES
CASTING AN OBJECT REFERENCE (MOVING LOWER ON THE INHERITANCE TREE)
DEADLY DIAMOND OF DEATH (MULTIPLE INHERITANCE PROBLEM) USING INTERFACES
(DIE BEST SOLUTION!) EXERCISES AND PUZZLES 200 201 203 206 208 211 213
214 215 216 223 224 230 XIII * *A IS ASSIGNED A ORI^AL IT) *FIRST
P»TK A T LIFE AND DEATH OF AN OBJECT OBJECTS ARE BORN AND OBJECTS DIE.
YOU RE IN CHARGE. YOU DECIDE WHEN AND HOW TO CONSTRUCT THEM. YOU DECIDE
WHEN TO ABANDON THEM. THE GARBAGE COLLECTOR (GC) RECLAIMS THE MEMORY.
WE LL LOOK AT HOW OBJECTS ARE CREATED, WHERE THEY LIVE, AND HOW TO KEEP
OR ABANDON THEM EFFICIENTLY.THAT MEANS WE LL TALK ABOUT THE HEAP, THE
STACK, SCOPE, CONSTRUCTORS, SUPER CONSTRUCTORS, NULL REFERENCES, AND GC
ELIGIBILITY. THE STACK AND THE HEAP, WHERE OBJECTS AND VARIABLES LIVE
236 METHODS ON THE STACK 237 WHERE LOCAL VARIABLES LIVE 238 WHERE
INSTANCE VARIABLES LIVE 239 THE MIRACLE OF OBJECT CREATION 240
CONSTRUCTORS (THE CODE THAT RUNS WHEN YOU SAY NEW) 241 INITIALIZING THE
STATE OF A NEW DUCK 243 OVERLOADED CONSTRUCTORS 247 SUPERCLASS
CONSTRUCTORS (CONSTRUCTOR CHAINING) 250 INVOKING OVERLOADED CONSTRUCTORS
USING THISQ 256 LIFE OF AN OBJECT 258 GARBAGE COLLECTION (AND MAKING
OBJECTS ELIGIBLE) 260 EXERCISES AND PUZZLES 266 VVTK OBJECT, LEAVM 9
BJECT ABANDONED- THAT STATIC VARIABLES ARE SHARED BY ALL INSTANCES OF A
CLASS. STATIC VARIABLE: KID 10 NUMBERS MATTER DO THE MATH. THE JAVA API
HAS METHODS FOR ABSOLUTE VALUE, ROUNDING, MIN/MAX, ETC. BUT WHAT ABOUT
FORMATTING? YOU MIGHT WANT NUMBERS TO PRINT EXACTLY TWO DECIMAL POINTS,
OR WITH COMMAS IN ALL THE RIGHT PLACES. AND YOU MIGHT WANT TO PRINT AND
MANIPULATE DATES, TOO. AND WHAT ABOUT PARSING A STRING INTO A NUMBER? OR
TURNING A NUMBER INTO A STRING? WE LL START BY LEARNING WHAT IT MEANS
FOR A VARIABLE OR METHOD TO BE STATIC. INSTANCE VARIABLES: ONE PER
INSTANCE STATIC VARIABLES: ONE PER T M MATH CLASS (DO YOU REALLY NEED AN
INSTANCE OF IT?) STATIC METHODS STATIC VARIABLES CONSTANTS (STATIC FINAL
VARIABLES) MATH METHODS (RANDOMQ, ROUNDQ, ABS(), ETC.) WRAPPER CLASSES
(INTEGER, BOOLEAN, CHARACTER, ETC.) AUTOBOXING NUMBER FORMATTING DATE
FORMATTING AND MANIPULATION STATIC IMPORTS EXERCISES AND PUZZLES 274 275
277 282 286 287 289 294 301 307 310 XIV 1 1 YOUR RISKY BEHAVIOR STUFF
HAPPENS. THE FILE ISN T THERE.THE SERVER IS DOWN. NO MATTER HOW GOOD A
PROGRAMMER YOU ARE, YOU CAN T CONTROL EVERYTHING. WHEN YOU WRITE A RISKY
METHOD, YOU NEED CODE TO HANDLE THE BAD THINGS THAT MIGHT HAPPEN. BUT
HOW DO YOU KNOW WHEN A METHOD IS RISKY? WHERE DO YOU PUT THE CODE TO
HANDLE THE EXCEPTIONAL SITUATION? IN THIS CHAPTER, WE RE GOING TO BUILD
A MIDI MUSIC PLAYER, THAT USES THE RISKY JAVASOUND API, SO WE BETTER
FIND OUT. MAKING A MUSIC MACHINE (THE BEATBOX) 316 WHAT IF YOU NEED TO
CALL RISKY CODE? 319 EXCEPTIONS SAY SOMETHING BAD MAY HAVE HAPPENED...
320 THE COMPILER GUARANTEES (IT CHECKS) THAT YOU RE AWARE OF THE RISKS
321 CATCHING EXCEPTIONS USING A TRY/CATCH (SKATEBOARDER) 322 FLOW
CONTROL IN TRY/CATCH BLOCKS 326 THE FINALLY BLOCK (NO MATTER WHAT
HAPPENS, TURN OFF THE OVEN!) 327 CATCHING MULTIPLE EXCEPTIONS (THE ORDER
MATTERS) 329 DECLARING AN EXCEPTION (JUST DUCK IT) 335 HANDLE OR DECLARE
LAW 337 CODE KITCHEN (MAKING SOUNDS) 339 EXERCISES AND PUZZLES 348 CLASS
WITH A RISKY METHOD 1 2 CLASS MYOUTER { CLASS MYLNNER { VOID GO() { THE
OUTER AND INNER OBJECTS ARE NOW INTIMATELY LINKED. A VERY GRAPHIC STORY
FACE IT, YOU NEED TO MAKE GUIS. EVEN IF YOU BELIEVE THAT FOR THE REST OF
YOUR LIFE YOU LL WRITE ONLY SERVER-SIDE CODE, SOONER OR LATER YOU LL
NEED TO WRITE TOOLS, AND YOU LL WANT A GRAPHICAL INTERFACE. WE LL SPEND
TWO CHAPTERS ON GUIS, AND LEARN MORE LANGUAGE FEATURES INCLUDING EVENT
HANDLING AND INNER CLASSES. WE LL PUT A BUTTON ON THE SCREEN, WE LL
PAINT ON THE SCREEN, WE LL DISPLAY A JPEG IMAGE, AND WE LL EVEN DO SOME
ANIMATION. YOUR FIRST GUI 355 GETTING A USER EVENT 357 IMPLEMENT A
LISTENER INTERFACE 358 GETTING A BUTTON S ACTIONEVENT 360 PUTTING
GRAPHICS ON A GUI 363 FUN WITH PAINTCOMPONENTQ 365 THE GRAPHICS2D OBJECT
366 PUTTING MORE THAN ONE BUTTON ON A SCREEN 370 INNER CLASSES TO THE
RESCUE (MAKE YOUR LISTENER AN INNER CLASS) 376 ANIMATION (MOVE IT, PAINT
IT, MOVE IT, PAINT IT, MOVE IT, PAINT IT...) 382 CODE KITCHEN (PAINTING
GRAPHICS WITH THE BEAT OF THE MUSIC) 386 EXERCISES AND PUZZLES 394 XV 1
3 THINGS IN THE NORTH AND SOUTH 3ET THEIR PRE-FERRED WORK ON YOUR SWING
SWING IS EASY. UNLESS YOU ACTUALLY CARE WHERE EVERYTHING GOES. SWING
CODE LOOKS EASY, BUT THEN COMPILE IT, RUN IT, LOOK AT IT AND THINK, HEY,
THAT S NOT SUPPOSED TO GO THERE. THE THING THAT MAKES IT EASY TO CODE
IS THE THING THAT MAKES IT HARD TO CONTROL *THE LAYOUT MANAGER. BUT WITH
A LITTLE WORK, YOU CAN GET LAYOUT MANAGERS TO SUBMIT TO YOUR WILL. IN
THIS CHAPTER, WE LL WORK ON OUR SWING AND LEARN MORE ABOUT WIDGETS.
SWING COMPONENTS 400 LAYOUT MANAGERS (THEY CONTROL SIZE AND PLACEMENT)
401 THREE LAYOUT MANAGERS (BORDER, FLOW, BOX) 403 BORDERLAYOUT (CARES
ABOUT FIVE REGIONS) 404 FLOWLAYOUT (CARES ABOUT THE ORDER AND PREFERRED
SIZE) 408 BOXLAYOUT (LIKE FLOW, BUT CAN STACK COMPONENTS VERTICALLY) 411
JTEXTFIELD (FOR SINGLE-LINE USER INPUT) 413 JTEXTAREA (FOR MULTI-LINE,
SCROLLING TEXT) 414 JCHECKBOX (IS IT SELECTED?) 416 JLIST (A SCROLLABLE,
SELECTABLE LIST) 417 CODE KITCHEN (THE BIG ONE - BUILDING THE BEATBOX
CHAT CLIENT) 418 EXERCISES AND PUZZLES 424 1 4 SAVING OBJECTS OBJECTS
CAN BE FLATTENED AND INFLATED. OBJECT S HAVE STATE AND BEHAVIOR.
BEHAVIOR LIVES IN THE CLASS, BUT STATE LIVES WITHIN EACH INDIVIDUAL
OBJECT. IF YOUR PROGRAM NEEDS TO SAVE STATE, YOU CAN DO IT THE HARD WAY,
INTERROGATING EACH OBJECT, PAINSTAKINGLY WRITING THE VALUE OF EACH
INSTANCE VARIABLE. OR, YOU CAN DO IT THE EASY OO WAY *YOU SIMPLY
FREEZE-DRY THE OBJECT (SERIALIZE IT) AND RECONSTITUTE (DESERIALIZE) IT
TO GET IT BACK. SAVING OBJECT STATE WRITING A SERIALIZED OBJECT TO A
FILE JAVA INPUT AND OUTPUT STREAMS (CONNECTIONS AND CHAINS) OBJECT
SERIALIZATION IMPLEMENTING THE SERIALIZABLE INTERFACE USING TRANSIENT
VARIABLES DESERIALIZING AN OBJECT WRITING TO A TEXT FILE JAVA.IO.FILE
READING FROM A TEXT FILE SPLITTING A STRING INTO TOKENS WITH SPLITQ
CODEKITCHEN EXERCISES AND PUZZLES 431 432 433 434 437 439 441 447 452
454 458 462 466 XVI 1 5 MAKE A CONNECTION CONNECT WITH THE OUTSIDE
WORLD. IT S EASY. ALL THE LOW LEVEL NETWORKING DETAILS ARE TAKEN CARE OF
BY CLASSES IN THE JAVA.NET LIBRARY. ONE OF JAVA S BEST FEATURES IS THAT
SENDING AND RECEIVING DATA OVER A NETWORK IS REALLY JUST I/O WITH A
SLIGHTLY DIFFERENT CONNECTION STREAM AT THE END OF THE CHAIN. IN THIS
CHAPTER WE LL MAKE CLIENT SOCKETS. WE LL MAKE SERVER SOCKETS. WE LL MAKE
CLIENTS AND SERVERS. BEFORE THE CHAPTER S DONE, YOU LL HAVE A
FULLY-FUNCTIONAL, MULTITHREADED CHAT CLIENT. DID WE JUST SAY
MULTITHREADEDL CHAT PROGRAM OVERVIEW 473 CONNECTING, SENDING, AND
RECEIVING 474 NETWORK SOCKETS 475 TCP PORTS 476 READING DATA FROM A
SOCKET (USING BUFFEREDREADER) 478 WRITING DATA TO A SOCKET (USING
PRINTWRITER) 479 WRITING THE DAILY ADVICE CLIENT PROGRAM 480 WRITING A
SIMPLE SERVER 483 DAILY ADVICE SERVER CODE 484 WRITING A CHAT CLIENT 486
MULTIPLE CALL STACKS 490 LAUNCHING A NEW THREAD (MAKE IT, START IT) 492
THE RUNNABLE INTERFACE (THE THREAD S JOB) 494 THREE STATES OF A NEW
THREAD OBJECT (NEW, RUNNABLE, RUNNING) 495 THE RUNNABLE-RUNNING LOOP 496
THREAD SCHEDULER (IT S HIS DECISION, NOT YOURS) 497 PUTTING A THREAD TO
SLEEP 501 MAKING AND STARTING TWO THREADS 503 CONCURRENCY ISSUES: CAN
THIS COUPLE BE SAVED? 505 THE RYAN AND MONICA CONCURRENCY PROBLEM, IN
CODE 506 LOCKING TO MAKE THINGS ATOMIC 510 EVERY OBJECT HAS A LOCK 511
THE DREADED LOST UPDATE PROBLEM 512 SYNCHRONIZED METHODS (USING A
LOCK) 514 DEADLOCK! 516 MULTITHREADED CHATCLIENT CODE 518 READY-BAKE
SIMPLECHATSERVER 520 EXERCISES AND PUZZLES 524 XVII 1 6 LIST SET MAP
MYAPP.JAR DATA STRUCTURES SORTING IS A SNAP IN JAVA. YOU HAVE ALL THE
TOOLS FOR COLLECTING AND MANIPULATING YOUR DATA WITHOUT HAVING TO WRITE
YOUR OWN SORT ALGORITHMS THE JAVA COLLECTIONS FRAMEWORK HAS A DATA
STRUCTURE THAT SHOULD WORK FOR VIRTUALLY ANYTHING YOU LL EVER NEED TO
DO. WANT TO KEEP A LIST THAT YOU CAN EASILY KEEP ADDING TO? WANT TO FIND
SOMETHING BY NAME? WANT TO CREATE A LIST THAT AUTOMATICALLY TAKES OUT
ALL THE DUPLICATES? SORT YOUR CO- WORKERS BY THE NUMBER OF TIMES THEY VE
STABBED YOU IN THE BACK? COLLECTIONS SORTING AN ARRAYLIST WITH
COLLECTIONS.SORTO GENERICS AND TYPE-SAFETY SORTING THINGS THAT IMPLEMENT
THE COMPARABLE INTERFACE SORTING THINGS WITH A CUSTOM COMPARATOR THE
COLLECTION API*LISTS, SETS, AND MAPS AVOIDING DUPLICATES WITH HASHSET
OVERRIDING HASHCODE() AND EQUALS)} HASHMAP USING WILDCARDS FOR
POLYMORPHISM EXERCISES AND PUZZLES 533 534 540 547 552 557 559 560 567
574 576 1 7 RELEASE YOUR CODE IT S TIME TO LET GO. YOU WROTE YOUR CODE.
YOU TESTED YOUR CODE. YOU REFINED YOUR CODE. YOU TOLD EVERYONE YOU KNOW
THAT IF YOU NEVER SAW A LINE OF CODE AGAIN, THAT D BE FINE. BUT IN THE
END, YOU VE CREATED A WORK OF ART. THE THING ACTUALLY RUNS! BUT NOW
WHAT? IN THESE FINAL TWO CHAPTERS, WE LL EXPLORE HOW TO ORGANIZE,
PACKAGE, AND DEPLOY YOUR JAVA CODE. WE LL LOOK AT LOCAL, SEMI-LOCAL, AND
REMOTE DEPLOYMENT OPTIONS INCLUDING EXECUTABLE JARS, JAVA WEB START,
RMI, AND SERVLETS. RELAX. SOME OF THE COOLEST THINGS IN JAVA ARE EASIER
THAN YOU THINK. MYAPP.CLASS DEPLOYMENT OPTIONS KEEP YOUR SOURCE CODE AND
CLASS FILES SEPARATE MAKING AN EXECUTABLE JAR (JAVA ARCHIVES) RUNNING AN
EXECUTABLE JAR PUT YOUR CLASSES IN A PACKAGE! PACKAGES MUST HAVE A
MATCHING DIRECTORY STRUCTURE COMPILING AND RUNNING WITH PACKAGES
COMPILING WITH -D MAKING AN EXECUTABLE JAR (WITH PACKAGES) JAVA WEB
START (JWS) FOR DEPLOYMENT FROM THE WEB HOW TO MAKE AND DEPLOY A JWS
APPLICATION EXERCISES AND PUZZLES 582 584 585 586 587 589 590 591 592
597 600 601 XVIII
|
adam_txt |
HEAD FIRST JAVA* SECOND EDITION WOULDN'T IT BE DREAMY IF THERE WAS A
JAVA BOOK THAT WAS MORE STIMULATING THAN WAITING IN LINE AT THE DAAV TO
RENEW YOUR DRIVER'S LICENSE? IT'S PROBABLY JUST A FANTASY. KATHY
SIERRA BERT BATES BEIJING * CAMBRIDGE * KOLN O'REILLY* PARIS *
SEBASTOPOL * TAIPEI * TOKYO 1 BREAKING THE SURFACE JAVA TAKES YOU TO NEW
PLACES. FROM ITS HUMBLE RELEASE TO THE PUBLIC AS THE (WIMPY) VERSION
1.02, JAVA SEDUCED PROGRAMMERS WITH ITS FRIENDLY SYNTAX, OBJECT-ORIENTED
FEATURES, MEMORY MANAGEMENT, AND BEST OF ALL*THE PROMISE OF PORTABILITY.
WE'LL TAKE A QUICK DIP AND WRITE SOME CODE, COMPILE IT, AND RUN IT.
WE'RE TALKING SYNTAX, LOOPS, BRANCHING, AND WHAT MAKES JAVA SO COOL.
DIVE IN. VIRTUAL MACHINES METHOD PARTY() 0 ALOAD _0 1 INVOKESPE- CIAL#1
JAVA.LANG.OBJECT() 4 RETURN BYTECODE THE WAY JAVA WORKS CODE STRUCTURE
IN JAVA ANATOMY OF A CLASS THE MAINQ METHOD LOOPING CONDITIONAL
BRANCHING (IF TESTS) CODING THE "99 BOTTLES OF BEER" APP PHRASE-O-MATIC
FIRESIDE CHAT: COMPILER VS. JVM EXERCISES AND PUZZLES 2 7 8 9 11 13 14
16 18 20 2 A TRIP TO OBJECTVILLE I WAS TOLD THERE WOULD BE OBJECTS. IN
CHAPTER 1,WE PUT ALL OF OUR CODE IN THE MAIN() METHOD. THAT'S NOT
EXACTLY OBJECT-ORIENTED. SO NOW WE'VE GOT TO LEAVE THAT PROCEDURAL WORLD
BEHIND AND START MAKING SOME OBJECTS OF OUR OWN. WE'LL LOOK AT WHAT
MAKES OBJECT-ORIENTED (00) DEVELOPMENT IN JAVA SO MUCH FUN. WE'LL LOOK
AT THE DIFFERENCE BETWEEN A CLASS AND AN OBJECT. WE'LL LOOK AT HOW
OBJECTS CAN IMPROVE YOUR LIFE. MANY OBJECTS CHAIR WARS (BRAD THE OO GUY
VS. LARRY THE PROCEDURAL GUY) INHERITANCE (AN INTRODUCTION) OVERRIDING
METHODS (AN INTRODUCTION) WHAT'S IN A CLASS? (METHODS, INSTANCE
VARIABLES) MAKING YOUR FIRST OBJECT USING MAINQ GUESSING GAME CODE
EXERCISES AND PUZZLES 28 31 32 34 36 38 39 42 R 3 KNOW YOUR VARIABLES
VARIABLES COME IN TWO FLAVORS: PRIMITIVE AND REFERENCE. THERE'S GOTTA BE
MORE TO LIFE THAN INTEGERS. STRINGS, AND ARRAYS. WHAT IF YOU HAVE A
PETOWNER OBJECT WITH A DOG INSTANCE VARIABLE? OR A CAR WITH AN ENGINE?
IN THIS CHAPTER WE'LL UNWRAP THE MYSTERIES OF JAVA TYPES AND LOOKAT WHAT
YOU CAN DECLARE AS A VARIABLE, WHAT YOU CAN PUT IN A VARIABLE, AND WHAT
YOU CAN DO WITH A VARIABLE. AND WE'LL FINALLY SEE WHAT LIFE IS TRULY
LIKE ON THE GARBAGE-COLLECTIBLE HEAP. DECLARING A VARIABLE (JAVA CARES
ABOUT TYPE) PRIMITIVE TYPES ("I'D LIKE A DOUBLE WITH EXTRA FOAM,
PLEASE") JAVA KEYWORDS REFERENCE VARIABLES (REMOTE CONTROL TO AN OBJECT)
OBJECT DECLARATION AND ASSIGNMENT OBJECTS ON THE GARBAGE-COLLECTIBLE
HEAP ARRAYS (A FIRST LOOK) EXERCISES AND PUZZLES 50 51 53 54 55 57 59 63
DOG REFERENCE 4 HOW OBJECTS BEHAVE STATE AFFECTS BEHAVIOR, BEHAVIOR
AFFECTS STATE, WE KNOW THAT OBJECTS HAVE STATE AND BEHAVIOR, REPRESENTED
BY INSTANCE VARIABLES AND METHODS. NOW WE'LL LOOK AT HOW STATE AND
BEHAVIOR ARE RELATED. AN OBJECT'S BEHAVIOR USES AN OBJECT'S UNIQUE
STATE. IN OTHER WORDS, METHODS USE INSTANCE VARIABLE VALUES. LIKE, "IF
DOG WEIGHT IS LESS THAN 14 POUNDS, MAKE YIPPY SOUND, ELSE." LET'S GO
CHANGE SOME STATE! PASS-BY-VALUE MEANS PASS-BY-COPY INT F OO . GO (X) ;
METHODS USE OBJECT STATE (BARK DIFFERENT) METHOD ARGUMENTS AND RETURN
TYPES PASS-BY-VALUE (THE VARIABLE IS ALWAYS COPIED) GETTERS AND SETTERS
ENCAPSULATION (DO IT OR RISK HUMILIATION) USING REFERENCES IN AN ARRAY
EXERCISES AND PUZZLES 73 74 77 79 80 83 VOID GO(INT Z) { } XI 5 TO* A B
C D E F G G 5 !TS.C ASL M ME.C EXTRA-STRENGTH METHODS LET'S PUT SOME
MUSCLE IN OUR METHODS. YOU DABBLED WITH VARIABLES, PLAYED WITH A FEW
OBJECTS, AND WROTE A LITTLE CODE. BUT YOU NEED MORE TOOLS. LIKE
OPERATORS. AND LOOPS. MIGHT BE USEFUL TO GENERATE RANDOM NUMBERS. AND
TURN A STRING INTO AN INT, YEAH, THAT WOULD BE COOL. AND WHY DON'T WE
LEARN IT ALL BY BUILDING SOMETHING REAL, TO SEE WHAT IT'S LIKE TO WRITE
(AND TEST) A PROGRAM FROM SCRATCH. MAYB E A GAME, LIKE SINK A DOT COM
(SIMILAR TO BATTLESHIP). BUILDING THE SINK A DOT COM GAME 96 STARTING
WITH THE SIMPLE DOT COM GAME (A SIMPLER VERSION) 98 WRITING PREPCODE
(PSEUDOCODE FOR THE GAME) 100 TEST CODE FOR SIMPLE DOT COM 102 CODING
THE SIMPLE DOT COM GAME 103 FINAL CODE FOR SIMPLE DOT COM 106 GENERATING
RANDOM NUMBERS WITH MATH.RANDOM() 111 READY-BAKE CODE FOR GETTING USER
INPUT FROM THE COMMAND-LINE 112 LOOPING WITH FOR LOOPS 114 CASTING
PRIMITIVES FROM A LARGE SIZE TO A SMALLER SIZE 117 CONVERTING A STRING
TO AN INT WITH INTEGER.PARSELNTO 117 EXERCISES AND PUZZLES 118 6 USING
THE JAVA LIBRARY JAVA SHIPS WITH HUNDREDS OF PRE-BUILT CLASSES, YOU
DON'T HAVE TO REINVENT THE WHEEL IF YOU KNOW HOW TO FIND WHAT YOU NEED
FROM THE JAVA LIBRARY, COMMONLY KNOWN AS THE JAVA API. YOU'VE GOT BETTER
THINGS TO DO. IF YOU'RE GOING TO WRITE CODE, YOU MIGHT AS WELL WRITE
ONLY THE PARTS THAT ARE CUSTOM FOR YOUR APPLICATION.THE CORE JAVA
LIBRARY IS A GIANT PILE OF CLASSES JUST WAITING FOR YOU TO USE LIKE
BUILDING BLOCKS. "GOOD TO KNOW THERE'S AN ARRAY LIST IN THE JAVA. UTIL
PACKAGE. BUT BY MYSELF, HOW WOULD I HAVE FIGURED THAT OUT?" - JULIA, 31,
HAND MODEL ANALYING THE BUG IN THE SIMPLE DOT COM GAME ARRAY LIST
(TAKING ADVANTAGE OF THE JAVA API) FIXING THE DOTCOM CLASS CODE BUILDING
THE REAL GAME (SINK A DOT COM) PREPCODE FOR THE REAL GAME CODE FOR THE
REAL GAME BOOLEAN EXPRESSIONS USING THE LIBRARY (JAVA API) USING
PACKAGES (IMPORT STATEMENTS, FULLY-QUALIFIED NAMES) USING THE HTML API
DOCS AND REFERENCE BOOKS EXERCISES AND PUZZLES 126 132 138 140 144 146
151 154 155 158 161 XII 7 BETTER LIVING IN OBJECTVILLE PLAN YOUR
PROGRAMS WITH THE FUTURE IN MIND, WHAT IF YOU COULD WRITE CODE THAT
SOMEONE ELSE COULD EXTEND, EASILY? WHAT IF YOU COULD WRITE CODE THAT WAS
FLEXIBLE, FOR THOSE PESKY LAST-MINUTE SPEC CHANGES? WHEN YOU GET ON THE
POLYMORPHISM PLAN, YOU'LL LEARN THE 5 STEPS TO BETTER CLASS DESIGN, THE
3 TRICKS TO POLYMORPHISM, THE 8 WAYS TO MAKE FLEXIBLE CODE, AND IF YOU
ACT NOW*A BONUS LESSON ON THE 4 TIPS FOR EXPLOITING INHERITANCE.
UNDERSTANDING INHERITANCE (SUPERCLASS AND SUBCLASS RELATIONSHIPS) 168
DESIGNING AN INHERITANCE TREE (THE ANIMAL SIMULATION) 170 AVOIDING
DUPLICATE CODE (USING INHERITANCE) 171 OVERRIDING METHODS 172 IS-A AND
HAS-A (BATHTUB GIRL) 17 7 WHAT DO YOU INHERIT FROM YOUR SUPERCLASS? 180
WHAT DOES INHERITANCE REALLY BUY YOU? 182 POLYMORPHISM (USING A
SUPERTYPE REFERENCE TO A SUBCLASS OBJECT) 183 RULES FOR OVERRIDING
(DON'T TOUCH THOSE ARGUMENTS AND RETURN TYPES!) 190 METHOD OVERLOADING
(NOTHING MORE THAN METHOD NAME RE-USE) 191 EXERCISES AND PUZZLES 192
SERIOUS POLYMORPHISM INHERITANCE IS JUST THE BEGINNING, TO EXPLOIT
POLYMORPHISM, WE NEED INTERFACES. WE NEED TO GO BEYOND SIMPLE
INHERITANCE TO FLEXIBILITY YOU CAN GET ONLY BY DESIGNING AND CODING TO
INTERFACES. WHAT'S AN INTERFACE? A 100% ABSTRACT CLASS. WHAT'S AN
ABSTRACT CLASS? A CLASS THAT CAN'T BE INSTANTIATED. WHAT'S THAT GOOD
FOR? READ THE CHAPTER. OBJECT O = AL.GET(ID); DOG D = (DOG) O;
D.BARK(); SOME CLASSES JUST SHOULD NOT BE INSTANTIATED ABSTRACT CLASSES
(CAN'T BE INSTANTIATED) ABSTRACT METHODS (MUST BE IMPLEMENTED)
POLYMORPHISM IN ACTION CLASS OBJECT (THE ULTIMATE SUPERCLASS OF
EVERYTHING) TAKING OBJECTS OUT OF AN ARRAYLIST (THEY COME OUT AS TYPE
OBJECT) COMPILER CHECKS THE REFERENCE TYPE (BEFORE LETTING YOU CALL A
MEDIOD) GET IN TOUCH WITH YOUR INNER OBJECT POLYMORPHIC REFERENCES
CASTING AN OBJECT REFERENCE (MOVING LOWER ON THE INHERITANCE TREE)
DEADLY DIAMOND OF DEATH (MULTIPLE INHERITANCE PROBLEM) USING INTERFACES
(DIE BEST SOLUTION!) EXERCISES AND PUZZLES 200 201 203 206 208 211 213
214 215 216 223 224 230 XIII * *A' IS ASSIGNED A ORI^AL IT) *FIRST
P»TK "A T LIFE AND DEATH OF AN OBJECT OBJECTS ARE BORN AND OBJECTS DIE.
YOU'RE IN CHARGE. YOU DECIDE WHEN AND HOW TO CONSTRUCT THEM. YOU DECIDE
WHEN TO ABANDON THEM. THE GARBAGE COLLECTOR (GC) RECLAIMS THE MEMORY.
WE'LL LOOK AT HOW OBJECTS ARE CREATED, WHERE THEY LIVE, AND HOW TO KEEP
OR ABANDON THEM EFFICIENTLY.THAT MEANS WE'LL TALK ABOUT THE HEAP, THE
STACK, SCOPE, CONSTRUCTORS, SUPER CONSTRUCTORS, NULL REFERENCES, AND GC
ELIGIBILITY. THE STACK AND THE HEAP, WHERE OBJECTS AND VARIABLES LIVE
236 METHODS ON THE STACK 237 WHERE LOCAL VARIABLES LIVE 238 WHERE
INSTANCE VARIABLES LIVE 239 THE MIRACLE OF OBJECT CREATION 240
CONSTRUCTORS (THE CODE THAT RUNS WHEN YOU SAY NEW) 241 INITIALIZING THE
STATE OF A NEW DUCK 243 OVERLOADED CONSTRUCTORS 247 SUPERCLASS
CONSTRUCTORS (CONSTRUCTOR CHAINING) 250 INVOKING OVERLOADED CONSTRUCTORS
USING THISQ 256 LIFE OF AN OBJECT 258 GARBAGE COLLECTION (AND MAKING
OBJECTS ELIGIBLE) 260 EXERCISES AND PUZZLES 266 VVTK OBJECT, LEAVM 9
BJECT ABANDONED- THAT STATIC VARIABLES ARE SHARED BY ALL INSTANCES OF A
CLASS. STATIC VARIABLE: KID 10 NUMBERS MATTER DO THE MATH. THE JAVA API
HAS METHODS FOR ABSOLUTE VALUE, ROUNDING, MIN/MAX, ETC. BUT WHAT ABOUT
FORMATTING? YOU MIGHT WANT NUMBERS TO PRINT EXACTLY TWO DECIMAL POINTS,
OR WITH COMMAS IN ALL THE RIGHT PLACES. AND YOU MIGHT WANT TO PRINT AND
MANIPULATE DATES, TOO. AND WHAT ABOUT PARSING A STRING INTO A NUMBER? OR
TURNING A NUMBER INTO A STRING? WE'LL START BY LEARNING WHAT IT MEANS
FOR A VARIABLE OR METHOD TO BE STATIC. INSTANCE VARIABLES: ONE PER
INSTANCE STATIC VARIABLES: ONE PER T\M MATH CLASS (DO YOU REALLY NEED AN
INSTANCE OF IT?) STATIC METHODS STATIC VARIABLES CONSTANTS (STATIC FINAL
VARIABLES) MATH METHODS (RANDOMQ, ROUNDQ, ABS(), ETC.) WRAPPER CLASSES
(INTEGER, BOOLEAN, CHARACTER, ETC.) AUTOBOXING NUMBER FORMATTING DATE
FORMATTING AND MANIPULATION STATIC IMPORTS EXERCISES AND PUZZLES 274 275
277 282 286 287 289 294 301 307 310 XIV 1 1 YOUR RISKY BEHAVIOR STUFF
HAPPENS. THE FILE ISN'T THERE.THE SERVER IS DOWN. NO MATTER HOW GOOD A
PROGRAMMER YOU ARE, YOU CAN'T CONTROL EVERYTHING. WHEN YOU WRITE A RISKY
METHOD, YOU NEED CODE TO HANDLE THE BAD THINGS THAT MIGHT HAPPEN. BUT
HOW DO YOU KNOW WHEN A METHOD IS RISKY? WHERE DO YOU PUT THE CODE TO
HANDLE THE EXCEPTIONAL SITUATION? IN THIS CHAPTER, WE'RE GOING TO BUILD
A MIDI MUSIC PLAYER, THAT USES THE RISKY JAVASOUND API, SO WE BETTER
FIND OUT. MAKING A MUSIC MACHINE (THE BEATBOX) 316 WHAT IF YOU NEED TO
CALL RISKY CODE? 319 EXCEPTIONS SAY "SOMETHING BAD MAY HAVE HAPPENED."
320 THE COMPILER GUARANTEES (IT CHECKS) THAT YOU'RE AWARE OF THE RISKS
321 CATCHING EXCEPTIONS USING A TRY/CATCH (SKATEBOARDER) 322 FLOW
CONTROL IN TRY/CATCH BLOCKS 326 THE FINALLY BLOCK (NO MATTER WHAT
HAPPENS, TURN OFF THE OVEN!) 327 CATCHING MULTIPLE EXCEPTIONS (THE ORDER
MATTERS) 329 DECLARING AN EXCEPTION (JUST DUCK IT) 335 HANDLE OR DECLARE
LAW 337 CODE KITCHEN (MAKING SOUNDS) 339 EXERCISES AND PUZZLES 348 CLASS
WITH A RISKY METHOD 1 2 CLASS MYOUTER { CLASS MYLNNER { VOID GO() { THE
OUTER AND INNER OBJECTS ARE NOW INTIMATELY LINKED. A VERY GRAPHIC STORY
FACE IT, YOU NEED TO MAKE GUIS. EVEN IF YOU BELIEVE THAT FOR THE REST OF
YOUR LIFE YOU'LL WRITE ONLY SERVER-SIDE CODE, SOONER OR LATER YOU'LL
NEED TO WRITE TOOLS, AND YOU'LL WANT A GRAPHICAL INTERFACE. WE'LL SPEND
TWO CHAPTERS ON GUIS, AND LEARN MORE LANGUAGE FEATURES INCLUDING EVENT
HANDLING AND INNER CLASSES. WE'LL PUT A BUTTON ON THE SCREEN, WE'LL
PAINT ON THE SCREEN, WE'LL DISPLAY A JPEG IMAGE, AND WE'LL EVEN DO SOME
ANIMATION. YOUR FIRST GUI 355 GETTING A USER EVENT 357 IMPLEMENT A
LISTENER INTERFACE 358 GETTING A BUTTON'S ACTIONEVENT 360 PUTTING
GRAPHICS ON A GUI 363 FUN WITH PAINTCOMPONENTQ 365 THE GRAPHICS2D OBJECT
366 PUTTING MORE THAN ONE BUTTON ON A SCREEN 370 INNER CLASSES TO THE
RESCUE (MAKE YOUR LISTENER AN INNER CLASS) 376 ANIMATION (MOVE IT, PAINT
IT, MOVE IT, PAINT IT, MOVE IT, PAINT IT.) 382 CODE KITCHEN (PAINTING
GRAPHICS WITH THE BEAT OF THE MUSIC) 386 EXERCISES AND PUZZLES 394 XV 1
3 THINGS IN THE NORTH AND SOUTH 3ET THEIR PRE-FERRED WORK ON YOUR SWING
SWING IS EASY. UNLESS YOU ACTUALLY CARE WHERE EVERYTHING GOES. SWING
CODE LOOKS EASY, BUT THEN COMPILE IT, RUN IT, LOOK AT IT AND THINK,"HEY,
THAT'S NOT SUPPOSED TO GO THERE." THE THING THAT MAKES IT EASY TO CODE
IS THE THING THAT MAKES IT HARD TO CONTROL *THE LAYOUT MANAGER. BUT WITH
A LITTLE WORK, YOU CAN GET LAYOUT MANAGERS TO SUBMIT TO YOUR WILL. IN
THIS CHAPTER, WE'LL WORK ON OUR SWING AND LEARN MORE ABOUT WIDGETS.
SWING COMPONENTS 400 LAYOUT MANAGERS (THEY CONTROL SIZE AND PLACEMENT)
401 THREE LAYOUT MANAGERS (BORDER, FLOW, BOX) 403 BORDERLAYOUT (CARES
ABOUT FIVE REGIONS) 404 FLOWLAYOUT (CARES ABOUT THE ORDER AND PREFERRED
SIZE) 408 BOXLAYOUT (LIKE FLOW, BUT CAN STACK COMPONENTS VERTICALLY) 411
JTEXTFIELD (FOR SINGLE-LINE USER INPUT) 413 JTEXTAREA (FOR MULTI-LINE,
SCROLLING TEXT) 414 JCHECKBOX (IS IT SELECTED?) 416 JLIST (A SCROLLABLE,
SELECTABLE LIST) 417 CODE KITCHEN (THE BIG ONE - BUILDING THE BEATBOX
CHAT CLIENT) 418 EXERCISES AND PUZZLES 424 1 4 SAVING OBJECTS OBJECTS
CAN BE FLATTENED AND INFLATED. OBJECT S HAVE STATE AND BEHAVIOR.
BEHAVIOR LIVES IN THE CLASS, BUT STATE LIVES WITHIN EACH INDIVIDUAL
OBJECT. IF YOUR PROGRAM NEEDS TO SAVE STATE, YOU CAN DO IT THE HARD WAY,
INTERROGATING EACH OBJECT, PAINSTAKINGLY WRITING THE VALUE OF EACH
INSTANCE VARIABLE. OR, YOU CAN DO IT THE EASY OO WAY *YOU SIMPLY
FREEZE-DRY THE OBJECT (SERIALIZE IT) AND RECONSTITUTE (DESERIALIZE) IT
TO GET IT BACK. SAVING OBJECT STATE WRITING A SERIALIZED OBJECT TO A
FILE JAVA INPUT AND OUTPUT STREAMS (CONNECTIONS AND CHAINS) OBJECT
SERIALIZATION IMPLEMENTING THE SERIALIZABLE INTERFACE USING TRANSIENT
VARIABLES DESERIALIZING AN OBJECT WRITING TO A TEXT FILE JAVA.IO.FILE
READING FROM A TEXT FILE SPLITTING A STRING INTO TOKENS WITH SPLITQ
CODEKITCHEN EXERCISES AND PUZZLES 431 432 433 434 437 439 441 447 452
454 458 462 466 XVI 1 5 MAKE A CONNECTION CONNECT WITH THE OUTSIDE
WORLD. IT'S EASY. ALL THE LOW LEVEL NETWORKING DETAILS ARE TAKEN CARE OF
BY CLASSES IN THE JAVA.NET LIBRARY. ONE OF JAVA'S BEST FEATURES IS THAT
SENDING AND RECEIVING DATA OVER A NETWORK IS REALLY JUST I/O WITH A
SLIGHTLY DIFFERENT CONNECTION STREAM AT THE END OF THE CHAIN. IN THIS
CHAPTER WE'LL MAKE CLIENT SOCKETS. WE'LL MAKE SERVER SOCKETS. WE'LL MAKE
CLIENTS AND SERVERS. BEFORE THE CHAPTER'S DONE, YOU'LL HAVE A
FULLY-FUNCTIONAL, MULTITHREADED CHAT CLIENT. DID WE JUST SAY
MULTITHREADEDL CHAT PROGRAM OVERVIEW 473 CONNECTING, SENDING, AND
RECEIVING 474 NETWORK SOCKETS 475 TCP PORTS 476 READING DATA FROM A
SOCKET (USING BUFFEREDREADER) 478 WRITING DATA TO A SOCKET (USING
PRINTWRITER) 479 WRITING THE DAILY ADVICE CLIENT PROGRAM 480 WRITING A
SIMPLE SERVER 483 DAILY ADVICE SERVER CODE 484 WRITING A CHAT CLIENT 486
MULTIPLE CALL STACKS 490 LAUNCHING A NEW THREAD (MAKE IT, START IT) 492
THE RUNNABLE INTERFACE (THE THREAD'S JOB) 494 THREE STATES OF A NEW
THREAD OBJECT (NEW, RUNNABLE, RUNNING) 495 THE RUNNABLE-RUNNING LOOP 496
THREAD SCHEDULER (IT'S HIS DECISION, NOT YOURS) 497 PUTTING A THREAD TO
SLEEP 501 MAKING AND STARTING TWO THREADS 503 CONCURRENCY ISSUES: CAN
THIS COUPLE BE SAVED? 505 THE RYAN AND MONICA CONCURRENCY PROBLEM, IN
CODE 506 LOCKING TO MAKE THINGS ATOMIC 510 EVERY OBJECT HAS A LOCK 511
THE DREADED "LOST UPDATE" PROBLEM 512 SYNCHRONIZED METHODS (USING A
LOCK) 514 DEADLOCK! 516 MULTITHREADED CHATCLIENT CODE 518 READY-BAKE
SIMPLECHATSERVER 520 EXERCISES AND PUZZLES 524 XVII 1 6 LIST SET MAP
MYAPP.JAR DATA STRUCTURES SORTING IS A SNAP IN JAVA. YOU HAVE ALL THE
TOOLS FOR COLLECTING AND MANIPULATING YOUR DATA WITHOUT HAVING TO WRITE
YOUR OWN SORT ALGORITHMS THE JAVA COLLECTIONS FRAMEWORK HAS A DATA
STRUCTURE THAT SHOULD WORK FOR VIRTUALLY ANYTHING YOU'LL EVER NEED TO
DO. WANT TO KEEP A LIST THAT YOU CAN EASILY KEEP ADDING TO? WANT TO FIND
SOMETHING BY NAME? WANT TO CREATE A LIST THAT AUTOMATICALLY TAKES OUT
ALL THE DUPLICATES? SORT YOUR CO- WORKERS BY THE NUMBER OF TIMES THEY'VE
STABBED YOU IN THE BACK? COLLECTIONS SORTING AN ARRAYLIST WITH
COLLECTIONS.SORTO GENERICS AND TYPE-SAFETY SORTING THINGS THAT IMPLEMENT
THE COMPARABLE INTERFACE SORTING THINGS WITH A CUSTOM COMPARATOR THE
COLLECTION API*LISTS, SETS, AND MAPS AVOIDING DUPLICATES WITH HASHSET
OVERRIDING HASHCODE() AND EQUALS)} HASHMAP USING WILDCARDS FOR
POLYMORPHISM EXERCISES AND PUZZLES 533 534 540 547 552 557 559 560 567
574 576 1 7 RELEASE YOUR CODE IT'S TIME TO LET GO. YOU WROTE YOUR CODE.
YOU TESTED YOUR CODE. YOU REFINED YOUR CODE. YOU TOLD EVERYONE YOU KNOW
THAT IF YOU NEVER SAW A LINE OF CODE AGAIN, THAT'D BE FINE. BUT IN THE
END, YOU'VE CREATED A WORK OF ART. THE THING ACTUALLY RUNS! BUT NOW
WHAT? IN THESE FINAL TWO CHAPTERS, WE'LL EXPLORE HOW TO ORGANIZE,
PACKAGE, AND DEPLOY YOUR JAVA CODE. WE'LL LOOK AT LOCAL, SEMI-LOCAL, AND
REMOTE DEPLOYMENT OPTIONS INCLUDING EXECUTABLE JARS, JAVA WEB START,
RMI, AND SERVLETS. RELAX. SOME OF THE COOLEST THINGS IN JAVA ARE EASIER
THAN YOU THINK. MYAPP.CLASS DEPLOYMENT OPTIONS KEEP YOUR SOURCE CODE AND
CLASS FILES SEPARATE MAKING AN EXECUTABLE JAR (JAVA ARCHIVES) RUNNING AN
EXECUTABLE JAR PUT YOUR CLASSES IN A PACKAGE! PACKAGES MUST HAVE A
MATCHING DIRECTORY STRUCTURE COMPILING AND RUNNING WITH PACKAGES
COMPILING WITH -D MAKING AN EXECUTABLE JAR (WITH PACKAGES) JAVA WEB
START (JWS) FOR DEPLOYMENT FROM THE WEB HOW TO MAKE AND DEPLOY A JWS
APPLICATION EXERCISES AND PUZZLES 582 584 585 586 587 589 590 591 592
597 600 601 XVIII |
any_adam_object | 1 |
any_adam_object_boolean | 1 |
author | Sierra, Kathy ca. 20./21. Jahrhundert Bates, Bert |
author_GND | (DE-588)119774696X |
author_facet | Sierra, Kathy ca. 20./21. Jahrhundert Bates, Bert |
author_role | aut aut |
author_sort | Sierra, Kathy ca. 20./21. Jahrhundert |
author_variant | k s ks b b bb |
building | Verbundindex |
bvnumber | BV020874540 |
callnumber-first | Q - Science |
callnumber-label | QA76 |
callnumber-raw | QA76.73.J38 |
callnumber-search | QA76.73.J38 |
callnumber-sort | QA 276.73 J38 |
callnumber-subject | QA - Mathematics |
classification_rvk | ST 250 |
ctrlnum | (OCoLC)254510658 (DE-599)BVBBV020874540 |
dewey-full | 005.133 |
dewey-hundreds | 000 - Computer science, information, general works |
dewey-ones | 005 - Computer programming, programs, data, security |
dewey-raw | 005.133 |
dewey-search | 005.133 |
dewey-sort | 15.133 |
dewey-tens | 000 - Computer science, information, general works |
discipline | Informatik |
discipline_str_mv | Informatik |
edition | 2. ed. |
format | Book |
fullrecord | <?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>02110nam a2200493 c 4500</leader><controlfield tag="001">BV020874540</controlfield><controlfield tag="003">DE-604</controlfield><controlfield tag="005">20191023 </controlfield><controlfield tag="007">t</controlfield><controlfield tag="008">051117s2005 gw a||| |||| 00||| eng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">0596009208</subfield><subfield code="9">0-596-00920-8</subfield></datafield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9780596009205</subfield><subfield code="9">978-0-596-00920-5</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)254510658</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DE-599)BVBBV020874540</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DE-604</subfield><subfield code="b">ger</subfield><subfield code="e">rakddb</subfield></datafield><datafield tag="041" ind1="0" ind2=" "><subfield code="a">eng</subfield></datafield><datafield tag="044" ind1=" " ind2=" "><subfield code="a">gw</subfield><subfield code="c">DE</subfield></datafield><datafield tag="049" ind1=" " ind2=" "><subfield code="a">DE-573</subfield><subfield code="a">DE-Aug4</subfield><subfield code="a">DE-473</subfield><subfield code="a">DE-1051</subfield><subfield code="a">DE-526</subfield><subfield code="a">DE-384</subfield><subfield code="a">DE-188</subfield><subfield code="a">DE-523</subfield><subfield code="a">DE-83</subfield><subfield code="a">DE-898</subfield></datafield><datafield tag="050" ind1=" " ind2="0"><subfield code="a">QA76.73.J38</subfield></datafield><datafield tag="082" ind1="0" ind2=" "><subfield code="a">005.133</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">ST 250</subfield><subfield code="0">(DE-625)143626:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Sierra, Kathy</subfield><subfield code="d">ca. 20./21. Jahrhundert</subfield><subfield code="e">Verfasser</subfield><subfield code="0">(DE-588)119774696X</subfield><subfield code="4">aut</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Head first Java</subfield><subfield code="b">[your brain on Java - a learner's guide]</subfield><subfield code="c">Kathy Sierra ; Bert Bates</subfield></datafield><datafield tag="250" ind1=" " ind2=" "><subfield code="a">2. ed.</subfield></datafield><datafield tag="264" ind1=" " ind2="1"><subfield code="a">Beijing [u.a.]</subfield><subfield code="b">O'Reilly</subfield><subfield code="c">2005</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">XXXII, 688 S.</subfield><subfield code="b">Ill.</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="b">txt</subfield><subfield code="2">rdacontent</subfield></datafield><datafield tag="337" ind1=" " ind2=" "><subfield code="b">n</subfield><subfield code="2">rdamedia</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="b">nc</subfield><subfield code="2">rdacarrier</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Java 2 Standard Edition 5.0 - Objektorientierte Programmierung</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Java (Computer program language)</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Java</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4401313-9</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Java 2 Standard Edition 5.0</subfield><subfield code="0">(DE-588)4799436-8</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Objektorientierte Programmierung</subfield><subfield code="0">(DE-588)4233947-9</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="689" ind1="0" ind2="0"><subfield code="a">Java</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4401313-9</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2="1"><subfield code="a">Objektorientierte Programmierung</subfield><subfield code="0">(DE-588)4233947-9</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2=" "><subfield code="5">DE-604</subfield></datafield><datafield tag="689" ind1="1" ind2="0"><subfield code="a">Java 2 Standard Edition 5.0</subfield><subfield code="0">(DE-588)4799436-8</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="1" ind2="1"><subfield code="a">Objektorientierte Programmierung</subfield><subfield code="0">(DE-588)4233947-9</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="1" ind2=" "><subfield code="5">DE-188</subfield></datafield><datafield tag="700" ind1="1" ind2=" "><subfield code="a">Bates, Bert</subfield><subfield code="e">Verfasser</subfield><subfield code="4">aut</subfield></datafield><datafield tag="856" ind1="4" ind2=" "><subfield code="u">http://www.ulb.tu-darmstadt.de/tocs/126586330.pdf</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="856" ind1="4" ind2="2"><subfield code="m">HEBIS Datenaustausch Darmstadt</subfield><subfield code="q">application/pdf</subfield><subfield code="u">http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=014196236&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="999" ind1=" " ind2=" "><subfield code="a">oai:aleph.bib-bvb.de:BVB01-014196236</subfield></datafield></record></collection> |
id | DE-604.BV020874540 |
illustrated | Illustrated |
index_date | 2024-07-02T13:27:02Z |
indexdate | 2024-07-09T20:27:13Z |
institution | BVB |
isbn | 0596009208 9780596009205 |
language | English |
oai_aleph_id | oai:aleph.bib-bvb.de:BVB01-014196236 |
oclc_num | 254510658 |
open_access_boolean | |
owner | DE-573 DE-Aug4 DE-473 DE-BY-UBG DE-1051 DE-526 DE-384 DE-188 DE-523 DE-83 DE-898 DE-BY-UBR |
owner_facet | DE-573 DE-Aug4 DE-473 DE-BY-UBG DE-1051 DE-526 DE-384 DE-188 DE-523 DE-83 DE-898 DE-BY-UBR |
physical | XXXII, 688 S. Ill. |
publishDate | 2005 |
publishDateSearch | 2005 |
publishDateSort | 2005 |
publisher | O'Reilly |
record_format | marc |
spelling | Sierra, Kathy ca. 20./21. Jahrhundert Verfasser (DE-588)119774696X aut Head first Java [your brain on Java - a learner's guide] Kathy Sierra ; Bert Bates 2. ed. Beijing [u.a.] O'Reilly 2005 XXXII, 688 S. Ill. txt rdacontent n rdamedia nc rdacarrier Java 2 Standard Edition 5.0 - Objektorientierte Programmierung Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd rswk-swf Java 2 Standard Edition 5.0 (DE-588)4799436-8 gnd rswk-swf Objektorientierte Programmierung (DE-588)4233947-9 gnd rswk-swf Java Programmiersprache (DE-588)4401313-9 s Objektorientierte Programmierung (DE-588)4233947-9 s DE-604 Java 2 Standard Edition 5.0 (DE-588)4799436-8 s DE-188 Bates, Bert Verfasser aut http://www.ulb.tu-darmstadt.de/tocs/126586330.pdf Inhaltsverzeichnis HEBIS Datenaustausch Darmstadt application/pdf http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=014196236&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA Inhaltsverzeichnis |
spellingShingle | Sierra, Kathy ca. 20./21. Jahrhundert Bates, Bert Head first Java [your brain on Java - a learner's guide] Java 2 Standard Edition 5.0 - Objektorientierte Programmierung Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd Java 2 Standard Edition 5.0 (DE-588)4799436-8 gnd Objektorientierte Programmierung (DE-588)4233947-9 gnd |
subject_GND | (DE-588)4401313-9 (DE-588)4799436-8 (DE-588)4233947-9 |
title | Head first Java [your brain on Java - a learner's guide] |
title_auth | Head first Java [your brain on Java - a learner's guide] |
title_exact_search | Head first Java [your brain on Java - a learner's guide] |
title_exact_search_txtP | Head first Java [your brain on Java - a learner's guide] |
title_full | Head first Java [your brain on Java - a learner's guide] Kathy Sierra ; Bert Bates |
title_fullStr | Head first Java [your brain on Java - a learner's guide] Kathy Sierra ; Bert Bates |
title_full_unstemmed | Head first Java [your brain on Java - a learner's guide] Kathy Sierra ; Bert Bates |
title_short | Head first Java |
title_sort | head first java your brain on java a learner s guide |
title_sub | [your brain on Java - a learner's guide] |
topic | Java 2 Standard Edition 5.0 - Objektorientierte Programmierung Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd Java 2 Standard Edition 5.0 (DE-588)4799436-8 gnd Objektorientierte Programmierung (DE-588)4233947-9 gnd |
topic_facet | Java 2 Standard Edition 5.0 - Objektorientierte Programmierung Java (Computer program language) Java Programmiersprache Java 2 Standard Edition 5.0 Objektorientierte Programmierung |
url | http://www.ulb.tu-darmstadt.de/tocs/126586330.pdf http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=014196236&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |
work_keys_str_mv | AT sierrakathy headfirstjavayourbrainonjavaalearnersguide AT batesbert headfirstjavayourbrainonjavaalearnersguide |
Es ist kein Print-Exemplar vorhanden.
Inhaltsverzeichnis