skip to content
Absolute Java Preview this item
ClosePreview this item

Absolute Java

Author: Walter J Savitch
Publisher: Boston, Mass. ; London : Pearson Education International, ©2010.
Edition/Format:   Print book : English : 4th ed. ; International edView all editions and formats

(not yet rated) 0 with reviews - Be the first.

More like this

Find a copy in the library

&AllPage.SpinnerRetrieving; Finding libraries that hold this item...


Document Type: Book
All Authors / Contributors: Walter J Savitch
ISBN: 9780131365896 0131365894
OCLC Number: 428890718
Notes: Previous edition: 2007.
Includes index.
Includes CD-ROM.
Description: 1 volume ; 24 cm
Contents: Chapter 1 Getting Started 11.1 INTRODUCTION TO JAVA 2Origins of the Java Language 2Objects and Methods 3Applets 4A Sample Java Application Program 5Byte-Code and the Java Virtual Machine 8Class Loader 10Compiling a Java Program or Class 10Running a Java Program 11Tip: Error Messages 121.2 EXPRESSIONS AND ASSIGNMENT STATEMENTS 13Identifiers 13Variables 15Assignment Statements 16Tip: Initialize Variables 18More Assignment Statements 19Assignment Compatibility 20Constants 21Arithmetic Operators and Expressions 23Parentheses and Precedence Rules 24Integer and Floating-Point Division 26Pitfall: Round-Off Errors in Floating-Point Numbers 27Pitfall: Division with Whole Numbers 28Type Casting 29Increment and Decrement Operators 301.3 THE CLASS STRING 33String Constants and Variables 33Concatenation of Strings 34Classes 35String Methods 37Escape Sequences 42String Processing 43The Unicode Character Set 431.4 PROGRAM STYLE 46Naming Constants 46Java Spelling Conventions 48Comments 49Indenting 50Chapter Summary 51Answers to Self-Test Exercises 52Programming Projects 54Chapter 2 Console Input and Output 572.1 SCREEN OUTPUT 58System.out.println 58Tip: Different Approaches to Formatting Output 61Formatting Output with printf 61Tip: Formatting Money Amounts with printf 65Tip: Legacy Code 66Money Formats Using NumberFormat 67Importing Packages and Classes 70The DecimalFormat Class 722.2 CONSOLE INPUT USING THE SCANNER CLASS 76The Scanner Class 76Pitfall: Dealing with the Line Terminator, '\n' 83The Empty String 84Tip: Prompt for Input 84Tip: Echo Input 84Example: Self-Service Check Out 86Other Input Delimiters 86Chapter Summary 89Answers to Self-Test Exercises 89Programming Projects 91Chapter 3 Flow of Control 953.1 BRANCHING MECHANISM 96if-else Statements 96Omitting the else 97Compound Statements 98Tip: Placing of Braces 99Nested Statements 100Multiway if-else Statement 100Example: State Income Tax 101The switch Statement 103Pitfall: Forgetting a break in a switch Statement 107The Conditional Operator 1083.2 BOOLEAN EXPRESSIONS 109Simple Boolean Expressions 109Pitfall: Using = in Place of == 110Pitfall: Using == with Strings 111Lexicographic and Alphabetical Order 112Building Boolean Expressions 115Pitfall: Strings of Inequalities 116Evaluating Boolean Expressions 116Tip: Naming Boolean Variables 119Short-Circuit and Complete Evaluation 120Precedence and Associativity Rules 1213.3 LOOPS 128while Statement and do-while Statement 128Algorithms and Pseudocode 130Example: Averaging a List of Scores 133The for Statement 134The Comma in for Statements 137Tip: Repeat N Times Loops 139Pitfall: Extra Semicolon in a for Statement 139Pitfall: Infinite Loops 140Nested Loops 141The break and continue Statements144The exit Statement 1453.4 DEBUGGING 146Loop Bugs 146Tracing Variables 146General Debugging Techniques 147Example: Debugging an Input Validation Loop 148Preventive Coding 152Assertion Checks 153Chapter Summary 155Answers to Self-Test Exercises 156Programming Projects 161Chapter 4 Defining Classes I 1674.1 CLASS DEFINITIONS 168Instance Variables and Methods 171More about Methods 174Tip: Any Method Can Be Used as a void Method 178Local Variables 180Blocks 181Tip: Declaring Variables in a for Statement 182Parameters of a Primitive Type 182Pitfall: Use of the Terms "Parameter" and "Argument" 189Simple Cases with Class Parameters 191The this Parameter 191Methods That Return a Boolean Value 193The Methods equals and toString 196Recursive Methods 199Tip: Testing Methods 1994.2 INFORMATION HIDING AND ENCAPSULATION 201public and private Modifiers 202Example: Yet Another Date Class 203Accessor and Mutator Methods 204Tip: A Class Has Access to Private Members of All Objects of the Class 209Tip: Mutator Methods Can Return a Boolean Value 210Preconditions and Postconditions 2114.3 OVERLOADING 212Rules for Overloading 212Pitfall: Overloading and Automatic Type Conversion 216Pitfall: You Cannot Overload Based on the Type Returned 2184.4 CONSTRUCTORS 220Constructor Definitions 220Tip: You Can Invoke Another Method in a Constructor 228Tip: A Constructor Has a this Parameter 228Tip: Include a No-Argument Constructor 229Example: The Final Date Class 230Default Variable Initializations 231An Alternative Way to Initialize Instance Variables 231Example: A Pet Record Class 232The StringTokenizer Class 236Chapter Summary 241Answers to Self-Test Exercises 242Programming Projects 247Chapter 5 Defining Classes II 2535.1 STATIC METHODS AND STATIC VARIABLES 255Static Methods 255Pitfall: Invoking a Nonstatic Method Within a Static Method 257Tip: You Can Put a main in Any Class 258Static Variables 262The Math Class 267Wrapper Classes 271Automatic Boxing and Unboxing 272Static Methods in Wrapper Classes 274Pitfall: A Wrapper Class Does Not Have a No-Argument Constructor 2775.2 REFERENCES AND CLASS PARAMETERS 278Variables and Memory 279References 280Class Parameters 285Pitfall: Use of = and == with Variables of a Class Type 289The Constant null 291Pitfall: Null Pointer Exception 292The new Operator and Anonymous Objects 292Example: Another Approach to Keyboard Input 293Tip: Use Static Imports 2955.3 USING AND MISUSING REFERENCES 297Example: A Person Class 298Pitfall: null Can Be an Argument to a Method 303Copy Constructors 307Pitfall: Privacy Leaks 309Tip: Deep Copy versus Shallow Copy 315Mutable and Immutable Classes 313Tip: Assume Your Coworkers Are Malicious 3165.4 PACKAGES AND JAVADOC 316Packages and import Statements 317The Package java.lang 318Package Names and Directories 318Pitfall: Subdirectories Are Not Automatically Imported 321The Default Package 321Pitfall: Not Including the Current Directory in Your Class Path 322Specifying a Class Path When You Compile 322Name Clashes 323Introduction to javadoc 324Commenting Classes for javadoc 324Running javadoc 326Chapter Summary 328Answers to Self-Test Exercises 329Programming Projects 333Chapter 6 Arrays 3396.1 INTRODUCTION TO ARRAYS 340Creating and Accessing Arrays 341The length Instance Variable 344Tip: Use for Loops with Arrays 346Pitfall: Array Indices Always Start with Zero 346Pitfall: Array Index Out of Bounds 346Initializing Arrays 347Pitfall: An Array of Characters Is Not a String 3496.2 ARRAYS AND REFERENCES 350Arrays Are Objects 350Pitfall: Arrays with a Class Base Type 352Array Parameters 352Pitfall: Use of = and == with Arrays 354Arguments for the Method main 359Methods that Return an Array 3616.3 PROGRAMMING WITH ARRAYS 362Partially Filled Arrays 363Example: A Class for Partially Filled Arrays 366Tip: Accessor Methods Need Not Simply Return Instance Variables 370The "for-each" Loop 370Methods with a Variable Number of Parameters 374Example: A String Processing Example 377Privacy Leaks with Array Instance Variables 378Example: Sorting an Array 382Enumerated Types 386Tip: Enumerated Types in switch Statements 3916.4 MULTIDIMENSIONAL ARRAYS 393Multidimensional Array Basics 393Using the length Instance Variable 396Ragged Arrays 397Multidimensional Array Parameters and Returned Values 397Example: A Grade Book Class 398Chapter Summary 404Answers to Self-Test Exercises 405Programming Projects 412Chapter 7 Inheritance 4197.1 INHERITANCE BASICS 420Derived Classes 421Overriding a Method Definition 431Changing the Return Type of an Overridden Method 431Changing the Access Permission of an Overridden Method 432Pitfall: Overriding versus Overloading 433The super Constructor 434The this Constructor 436Tip: An Object of a Derived Class Has More than One Type 437Pitfall: The Terms Subclass and Superclass 440Example: An Enhanced StringTokenizer Class 4417.2 ENCAPSULATION AND INHERITANCE 444Pitfall: Use of Private Instance Variables from the Base Class 444Pitfall: Private Methods Are Effectively Not Inherited 446Protected and Package Access 446Pitfall: Forgetting about the Default Package 448Pitfall: A Restriction on Protected Access 4507.3 PROGRAMMING WITH INHERITANCE 452Tip: Static Variables Are Inherited 452Tip: "is a" Versus "has a" 453Access to a Redefined Base Method 453Pitfall: You Cannot Use Multiple supers 454The Class Object 455The Right Way to Define equals 456Tip: getClass Versus instanceof 459Chapter Summary 464Answers to Self-Test Exercises 465Programming Projects 468Chapter 8 Polymorphism and Abstract Classes 4738.1 POLYMORPHISM 474Late Binding 475The final Modifier 477Example: Sales Records 478Late Binding with toString 485Pitfall: No Late Binding for Static Methods 486Downcasting and Upcasting 487Pitfall: Downcasting 491Tip: Checking to See Whether Downcasting Is Legitimate 491A First Look at the clone Method 494Pitfall: Sometimes the clone Method Return Type Is Object 495Pitfall: Limitations of Copy Constructors 4968.2 ABSTRACT CLASSES 500Abstract Classes 500Pitfall: You Cannot Create Instances of an Abstract Class 505Tip: An Abstract Class Is a Type 505Chapter Summary 507Answers to Self-Test Exercises 507Programming Projects 509Chapter 9 Exception Handling 5139.1 EXCEPTION HANDLING BASICS 515Example: A Toy Example of Exception Handling 515try-throw-catch Mechanism 520Exception Classes 524Exception Classes from Standard Packages 525Defining Exception Classes 527Tip: Preserve getMessage 531Tip: An Exception Class Can Carry a Message of Any Type 533Multiple catch Blocks 538Pitfall: Catch the More Specific Exception First 5409.2 THROWING EXCEPTIONS IN METHODS 542Throwing an Exception in a Method 543Declaring Exceptions in a throws Clause 545Exceptions to the Catch or Declare Rule 547v throws Clause in Derived Classes 549When to Use Exceptions 549Event-Driven Programming 5519.3 MORE PROGRAMMING TECHNIQUESFOR EXCEPTION HANDLING 552Pitfall: Nested try-catch Blocks 553The finally Block 553Rethrowing an Exception 555The AssertionError Class 555Exception Handling with the Scanner Class 555Tip: Exception Controlled Loops 556ArrayIndexOutOfBoundsException 558Chapter Summary 558Answers to Self-Test Exercises 559Programming Projects 563Chapter 10 File I/O 56710.1 INTRODUCTION TO FILE I/O 568Streams 569Text Files and Binary Files 56910.2 TEXT FILES 570Writing to a Text File 570Pitfall: A try Block Is a Block 576Pitfall: Overwriting an Output File 577Appending to a Text File 577Tip: toString Helps with Text File Output 578Reading from a Text File 580Reading a Text File Using Scanner 580Testing for the End of a Text File with Scanner 583Reading a Text File Using BufferedReader 590Tip: Reading Numbers with BufferedReader 594Testing for the End of a Text File with BufferedReader 594Path Names 597Nested Constructor Invocations, System.out, and System.err 59810.3 THE FILE CLASS 600Programming with the File Class 60110.4 BINARY FILES 604Writing Simple Data to a Binary File 605UTF and writeUTF 609Reading Simple Data from a Binary File 610Checking for the End of a Binary File 615Pitfall: Checking for the End of a File in the Wrong Way 617Binary I/O of Objects 618The Serializable Interface 618Pitfall: Mixing Class Types in the Same File 621Array Objects in Binary Files 62210.5 RANDOM ACCESS TO BINARY FILES 624Reading and Writing to the Same File 624Pitfall: A RandomAccessFile Need Not Start Empty 630Chapter Summary 630Answers to Self-Test Exercises 631Programming Projects 635Chapter 11 Recursion 63911.1 RECURSIVE VOID METHODS 641Example: Vertical Numbers 641Tracing a Recursive Call 644A Closer Look at Recursion 647Pitfall: Infinite Recursion 649Stacks for Recursion 650Pitfall: Stack Overflow 652Recursion versus Iteration 65211.2 RECURSIVE METHODS THAT RETURN A VALUE 653General Form for a Recursive Method That Returns a Value 653Example: Another Powers Method 65411.3 THINKING RECURSIVELY 659Recursive Design Techniques 659Binary Search 650Efficiency of Binary Search 666Chapter Summary 668Answers to Self-Test Exercises 669Programming Projects 672Chapter 12 UML and Patterns 67712.1 UML 678History of UML 679UML Class Diagrams 679Class Interactions 680Inheritance Diagrams 680More UML 68212.2 PATTERNS 683Adaptor Pattern 683The Model-View-Controller Pattern 684Example: A Sorting Pattern 685Restrictions on the Sorting Pattern 691Efficiency of the Sorting Pattern 691Tip: Pragmatics and Patterns 692Pattern Formalism 692Chapter Summary 693Answers to Self-Test Exercises 693Programming Projects 695Chapter 13 Interfaces and Inner Classes 69913.1 INTERFACES 701Interfaces 701Abstract Classes Implementing Interfaces 703Derived Interfaces 703Pitfall: Interface Semantics Are Not Enforced 705The Comparable Interface 707Example: Using the Comparable Interface 708Defined Constants in Interfaces 713Pitfall: Inconsistent Interfaces 714The Serializable Interface 717The Cloneable Interface 71713.2 SIMPLE USES OF INNER CLASSES 722Helping Classes 722Tip: Inner and Outer Classes Have Access to Each Other's Private Members 723Example: A Bank Account Class 723The .class File for an Inner Class 727Pitfall: Other Uses of Inner Classes 72813.3 MORE ABOUT INNER CLASSES 728Static Inner Classes 728Public Inner Classes 729Tip: Referring to a Method of the Outer Class 731Nesting Inner Classes 733Inner Classes and Inheritance 733Anonymous Classes 734Tip: Why Use Inner Classes? 736v Chapter Summary 737Answers to Self-Test Exercises 738Programming Projects 742Chapter 14 Generics and the ArrayList Class 74714.1 THE ARRAYLIST CLASS 749Using the ArrayList Class 750Tip: Summary of Adding to an ArrayList 754Methods in the Class ArrayList 755The "for-each" Loop 759Example: Golf Scores 762Tip: Use trimToSize to Save Memory 765Pitfall: The clone Method Makes a Shallow Copy 765The Vector Class 766Parameterized Classes and Generics 767Pitfall: Nonparameterized ArrayList and Vector Classes 76714.2 GENERICS 767Generic Basics 767Tip: Compile with the -Xlint Option 769Example: A Generic Class for Ordered Pairs 770Pitfall: A Generic Constructor Name Has No Type Parameter 773Pitfall: You Cannot Plug in a Primitive Type for a Type Parameter 774Pitfall: A Type Parameter Cannot Be Used Everywhere a Type Name Can Be Used 774Pitfall: An Instantiation of a Generic Class Cannot be an Array Base Type 774Tip: A Class Definition Can Have More Than One Type Parameter 775Pitfall: A Generic Class Cannot Be an Exception Class 777Bounds for Type Parameters 778Tip: Generic Interfaces 780Generic Methods 780Inheritance with Generic Classes 782Chapter Summary 784Answers to Self-Test Exercises 785Programming Projects 787Chapter 15 Linked Data Structures 79115.1 JAVA LINKED LISTS 794Example: A Simple Linked List Class 794Working with Linked Lists 798Pitfall: Privacy Leaks 803Node Inner Classes 804v Example: A Generic Linked List 807Pitfall: Using Node Instead of Node 812The equals Method for Linked Lists 81315.2 COPY CONSTRUCTORS AND THE CLONE METHOD 814Simple Copy Constructors and clone Methods 815Exceptions 815Pitfall: The clone Method Is Protected in Object 818Tip: Use a Type Parameter Bound for a Better clone 819Example: A Linked List with a Deep Copy clone Method 822Tip: Cloning Is an "All or Nothing" Affair 82615.3 ITERATORS 826Defining an Iterator Class 827Adding and Deleting Nodes 83215.4 VARIATIONS ON A LINKED LIST 835Doubly Linked List 837The Stack Data Structure 846The Queue Data Structure 848Running Times and Big-O Notation 851Efficiency of Linked Lists 85615.5 HASH TABLES WITH CHAINING 857A Hash Function for Strings 858Efficiency of Hash Tables 86215.6 SETS 863Fundamental Set Operations 863Efficiency of Sets Using Linked Lists 86815.7 TREES 869Tree Properties 870Example: A Binary Search Tree Class 872Efficiency of Binary Search Trees 878Chapter Summary 879Answers to Self-Test Exercises 880Programming Projects 885Chapter 16 Collections, Maps and Iterators 88916.1 COLLECTIONS 890Wildcards 892The Collection Framework 892Pitfall: Optional Operations 898Tip: Dealing with All Those Exceptions 899Concrete Collection Classes 900Differences Between ArrayList and Vector 909Nonparameterized Version of the Collection Framework 909Pitfall: Omitting the 91016.2 MAPS 910Concrete Map Classes 91316.3 ITERATORS 917The Iterator Concept 917The Iterator Interface 917Tip: For-Each Loops as Iterators 920List Iterators 921Pitfall: next Can Return a Reference 923Tip: Defining Your Own Iterator Classes 925Chapter Summary 926Answers to Self-Test Exercises 926Programming Projects 927Chapter 17 Swing I 93317.1 EVENT-DRIVEN PROGRAMMING 935Events and Listeners 93517.2 BUTTONS, EVENTS, AND OTHER SWING BASICS 936Example: A Simple Window 937Pitfall: Forgetting to Program the Close-Window Button 942Buttons 943Action Listeners and Action Events 944Pitfall: Changing the Heading for actionPerformed 946Tip: Ending a Swing Program 947Example: A Better Version of Our First Swing GUI 947Labels 951Color 952Example: A GUI with a Label and Color 95317.3 CONTAINERS AND LAYOUT MANAGERS 956Border Layout Managers 956Flow Layout Managers 959Grid Layout Managers 961Panels 965Example: A Tricolor Built with Panels 966The Container Class 970Tip: Code a GUI's Look and Actions Separately 973The Model-View-Controller Pattern 97417.4 MENUS AND BUTTONS 975Example: A GUI with a Menu 975Menu Bars, Menus, and Menu Items 975Nested Menus 980The AbstractButton Class 980The setActionCommand Method 983Listeners as Inner Classes 98517.5 TEXT FIELDS AND TEXT AREAS 988Text Areas and Text Fields 988Tip: Labeling a Text Field 994Tip: Inputting and Outputting Numbers 995A Swing Calculator 995Chapter Summary 1001Answers to Self-Test Exercises 1002Programming Projects 1009Chapter 18 Swing II 101118.1 WINDOW LISTENERS 1012Example: A Window Listener Inner Class 1014The dispose Method 1018Pitfall: Forgetting to Invoke setDefaultCloseOperation 1018The WindowAdapter Class 101918.2 ICONS AND SCROLL BARS 1020Icons 1020Scroll Bars 1027Example: Components with Changing Visibility 103318.3 THE GRAPHICS CLASS 1036Coordinate System for Graphics Objects 1037The Method paint and the Class Graphics 1037Drawing Ovals 1043Drawing Arcs 1043Rounded Rectangles 1047paintComponent for Panels 1048Action Drawings and repaint 1048Some More Details on Updating a GUI 105418.4 COLORS 1054Specifying a Drawing Color 1055Defining Colors 1056Pitfall: Using doubles to Define a Color 1057The JColorChooser Dialog Window 105818.5 FONTS AND THE DRAWSTRING METHOD 1061The drawString Method 1061Fonts 1064Chapter Summary 1067Answers to Self-Test Exercises 1068Programming Projects 1071Chapter 19 Java Never Ends 107719.1 MULTITHREADING 1078Example: A Nonresponsive GUI 1079Thread.sleep 1079The getGraphics Method 1083Fixing a Nonresponsive Program Using Threads 1084Example: A Multithreaded Program 1084The Class Thread 1085The Runnable Interface 108819.2 NETWORKING WITH STREAM SOCKETS 1091Sockets 1091Sockets and Threading 109519.3 JAVABEANS 1096The Component Model 1096The JavaBeans Model 109619.4 JAVA AND DATABASE CONNECTIONS 1098Relational Databases 1098Java DB and JDBC 1098SQL 110019.5 WEB PROGRAMMING WITH JAVA SERVER PAGES 1110Applets, Servlets, and Java Server Pages 1110Sun GlassFish Enterprise Server 1112HTML Forms-the Common Gateway Interface 1113JSP Declarations, Expressions, Scriptlets, and Directives 1115Chapter Summary 1124Answers to Self-Test Exercises 1124Programming Projects 1126Chapter 20 Applets and HTML (online at )Appendix 1 Keywords 1131Appendix 2 Precedence and Associativity Rules 1133Appendix 3 Unicode Character Set 1135Appendix 4 Format Specifications for printf 1137Appendix 5 Summary of Classes and Interfaces 1139Index 1207
Responsibility: Walter Savitch.


User-contributed reviews
Retrieving GoodReads reviews...
Retrieving DOGObooks reviews...


Be the first.

Similar Items

Confirm this request

You may have already requested this item. Please select Ok if you would like to proceed with this request anyway.

Linked Data

Primary Entity

<> # Absolute Java
    a schema:CreativeWork, schema:Book ;
   library:oclcnum "428890718" ;
   library:placeOfPublication <> ; # London
   library:placeOfPublication <> ; # Boston, Mass.
   library:placeOfPublication <> ;
   schema:about <> ; # Java (Computer program language)
   schema:about <> ; # JAVA (programspråk)
   schema:about <> ;
   schema:bookEdition "4th ed. ; International ed." ;
   schema:bookFormat bgn:PrintBook ;
   schema:copyrightYear "2010" ;
   schema:creator <> ; # Walter J. Savitch
   schema:datePublished "2010" ;
   schema:exampleOfWork <> ;
   schema:inLanguage "en" ;
   schema:name "Absolute Java"@en ;
   schema:productID "428890718" ;
   schema:publication <> ;
   schema:publisher <> ; # Pearson Education International
   schema:workExample <> ;
   umbel:isLike <> ;
   wdrs:describedby <> ;

Related Entities

<> # London
    a schema:Place ;
   schema:name "London" ;

<> # Pearson Education International
    a bgn:Agent ;
   schema:name "Pearson Education International" ;

<> # JAVA (programspråk)
    a schema:Intangible ;
   schema:name "JAVA (programspråk)"@en ;

<> # Java (Computer program language)
    a schema:Intangible ;
   schema:name "Java (Computer program language)"@en ;

<> # Walter J. Savitch
    a schema:Person ;
   schema:birthDate "1943" ;
   schema:familyName "Savitch" ;
   schema:givenName "Walter J." ;
   schema:name "Walter J. Savitch" ;

    a schema:ProductModel ;
   schema:isbn "0131365894" ;
   schema:isbn "9780131365896" ;

Content-negotiable representations

Close Window

Please sign in to WorldCat 

Don't have an account? You can easily create a free account.