Für diesen Artikel ist leider kein Bild verfügbar.

Thinking in Java

(Autor)

Buch | Softcover
1152 Seiten
1998
Prentice Hall (Verlag)
978-0-13-659723-0 (ISBN)
45,85 inkl. MwSt
zur Neuauflage
  • Titel erscheint in neuer Auflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
Covers the Java AWT, multithreading, network programming with Java - even design patterns. This book introduces all of the language's fundamentals, one step at a time, using to-the-point code examples. It introduces error handling, exceptions, Java I/O, run-time type identification, and passing and returning objects.
Thinking in Java is a "brash, arrogant, opinionated, independent, knowledgeable, interesting, readable book on Java." Eckel uses superb analogies between software concepts and everyday things to deliver a book ideal for teaching. It is unique because it was made available by Eckel on the Internet and so has been tested by thousands of users. Many of these people are waiting for the book to arrive.

Bruce Eckel is a corporate trainer and consultant who writes the Java column for Web Techniques Magazine.

What’s Inside.


Foreword.



Introduction.



Prerequisites.



Learning Java.



Goals.



Online Documentation.



Chapters.



Exercises.



Multimedia CD ROM.



Source Code.



Coding Standards.



Java Versions.



Seminars and Mentoring.



Errors.



Note on the Cover Design.



Acknowledgments.



1. Introduction to Objects.


The Progress of Abstraction.



An Object has an Interface.



The Hidden Implementation.



Reusing the Implementation.



Inheritance: Reusing the Interface.



Overriding base-Class Functionality.



Is-a vs. is-like-a Relationships.



Interchangeable Objects with Polymorphism.



Dynamic Binding.



Abstract Base Classes and Interfaces.



Object Landscapes and Lifetimes.



Collections and Iterators.



The Singly-Rooted Hierarchy.



Collection Libraries and Support for Easy Collection Use.



The Housekeeping Dilemma: Who Should Clean Up?



Exception Handling: Dealing with Errors.



Multithreading.



Persistence.



Java and the Internet.



What is the Web?



Client-side Programming.



Server-side Programming.



A separate arena: Applications.



Analysis and Design.



Staying on Course.



Phase 0: Let’s Make a Plan.



Phase 1: What are We Making?



Phase 2: How Will We Build It?



Phase 3: Let’s Build It!



Phase 4: Iteration.



Plans Pay Off.



Java vs. C++?



2. Everything is an Object.


You Manipulate Objects with Handles.



You Must Create All the Objects.



Where Storage Lives.



Special Case: Primitive Types.



Arrays in Java.



You Never Need to Destroy an Object.



Scoping.



Scope of Objects.



Creating New Data Types: Class.



Fields and Methods.



Methods, Arguments and Return Values.



The Argument List.



Building a Java Program.



Name Visibility.



Using Other Components.



The Static Keyword.



Your First Java Program.



Comments and Embedded Documentation.



Comment Documentation.



Syntax.



Embedded HTML.



See: Referring to Other Classes.



Class Documentation Tags.



Variable Documentation Tags.



Method Documentation Tags.



Documentation Example.



Coding style.



Summary.



Exercises.



3. Controlling Program Flow.


Using Java Operators.



Precedence.



Assignment.



Mathematical Operators.



Auto Increment and Decrement.



Relational Operators.



Logical Operators.



Bitwise Operators.



Shift Operators.



Ternary If-Else Operator.



The Comma Operator.



String Operator +.



Common pitfalls when using Operators.



Casting Operators.



Java has no “sizeof.”



Precedence Revisited.



A Compendium of Operator.



Execution Control.



True and False.



If-Else.



Iteration.



Do-While.



For.



Break and Continue Switch.



Summary.



Exercises.



4. Initialization and Cleanup.


Guaranteed Initialization with the Constructor.



Method Overloading.



Distinguishing Overloaded Methods.



Overloading with Primitives.



Overloading on Return Values.



Default Constructors.



The this Keyword.



Cleanup: Finalization and Garbage Collection.



What is Finalize( ) For?



You Must Perform Cleanup.



Member Initialization.



Specifying Initialization.



Constructor Initialization.



Array Initialization.



Multidimensional Arrays.



Summary.



Exercises.



5. Hiding the Implementation Package: The Library Unit.


Creating Unique Package Names.



A Custom Tool Library.



Using Imports to Change Behavior.



Package Caveat.



Java Access Specifiers “Friendly.”



Public: Interface Access.



Private: You Can’t Touch That!



Protected: “Sort of Friendly.”



Interface and Implementation.



Class Access.



Summary.



Exercises.



6. Reusing Classes.


Composition Syntax.



Inheritance Syntax.



Initializing the Base Class.



Combining Composition and Inheritance.



Guaranteeing Proper Cleanup.



Name Hiding.



Choosing Composition vs. Inheritance.



Protected.



Incremental Development.



Upcasting.



Why “Upcasting”?



The Final Keyword.



Final Data.



Final Methods.



Final Classes.



Final Caution.



Initialization and Class Loading.



Initialization with Inheritance.



Summary.



Exercises.



7. Polymorphism.


Upcasting.



Why Upcast?



The Twist.



Method Call Binding.



Producing the Right Behavior.



Extensibility.



Overriding vs. Overloading.



Abstract Classes and Methods.



Interfaces.



“Multiple Inheritance” in Java.



Extending an Interface with Inheritance.



Grouping Constants.



Initializing Fields in Interfaces.



Inner Classes.



Inner Classes and Upcasting.



Inner Classes in Methods and Scopes.



The Link to the Outer Class.



Static Inner Classes.



Referring to the Outer Class Object.



Inheriting from Inner Classes.



Can Inner Classes be Overridden?



Inner Class Identifiers.



Why Inner Classes: Control Frameworks.



Constructors and Polymorphism.



Order of Constructor Calls.



Inheritance and Finalize( ).



Behavior of Polymorphic Methods Inside Constructors.



Designing with Inheritance.



Pure Inheritance vs. Extension.



Downcasting and Run-Time Identification.



Summary.



Exercises.



8. Holding your Objects.


Arrays.



Arrays are First-Class Objects.



Returning an Array.



Collections.



Disadvantage: Unknown Type.



Enumerators (iterators).



Types of Collections.



Vector.



BitSet.



Stack.



Hashtable.



Enumerators Revisited.



Sorting.



The Generic Collection Library.



The New Collections.



Using Collections.



Using Lists.



Using Sets.



Using Maps.



Choosing an Implementation.



Unsupported Operations.



Sorting and Searching.



Utilities.



Summary.



Exercises.



9. Error Handling with Exceptions.


Basic Exceptions.



Exception Arguments.



Catching an Exception.



The Try Block.



Exception Handlers.



The Exception Specification.



Catching Any Exception.



Rethrowing an Exception.



Standard Java Exceptions.



The Special Case of Runtime Exception.



Creating Your Own Exceptions.



Exception Restrictions.



Performing Cleanup with Finally.



What’s Finally For?



Pitfall: The Lost Exception.



Constructors.



Exception Matching.



Exception Guidelines.



Summary.



Exercises.



10. The Java.


IO system.



Input and Output.



Types of InputStream.



Types of OutputStream.



Adding Attributes and Useful Interfaces.



Reading from an InputStream with FilterInputStream.



Writing to an OutputStream with FilterOutputStream.



Off by itself: RandomAccessFile.



The File Class.



A Directory Lister.



Checking For and Creating Directories.



Typical Uses of IO Streams.



Input Streams.



Output Streams.



Shorthand for File Manipulation.



Reading from Standard Input.



Piped Streams.



StreamTokenizer.



StringTokenizer.



Java 1.1 IO Streams.



Sources and Sinks of Data.



Modifying Stream Behavior.



Unchanged Classes.



An Example.



Redirecting Standard IO.



Compression.



Simple Compression with GZIP.



Multi-file Storage with Zip.



The Java Archive (jar) Utility.



Object Serialization.



Finding the Class.



Controlling Serialization.



Using Persistence.



Summary.



Exercises.



11. Run-Time Type.


Identification.



The Need for RTTI.



The Class Object.



Checking Before a Cast.



RTTI Syntax.



Reflection: Run-Time Class Information.



A Class Method Extractor



Summary.



Exercises.



12. Passing and Returning Objects.


Passing Handles Around.



Aliasing.



Making Local Copies.



Pass by Value.



Cloning Objects.



Adding Cloneability to a Class.



Successful Cloning.



The Effect of Object.clone( ).



Cloning a Composed Object.



A Deep Copy with Vector.



Deep Copy via Serialization.



Adding Cloneability Further Down a Hierarchy.



Why this Strange Design?



Controlling Cloneability.



The Copy-Constructor.



Read-only Classes.



Creating Read-only Classes.



The Drawback to Immutability.



Immutable Strings.



The String and StringBuffer Classes.



Strings are Special.



Summary.



Exercises.



13. Creating windows and Applets.


Why use the AWT?



The Basic Applet.



Testing Applets.



A More Graphical Example.



Demonstrating the Framework Methods.



Making a Button.



Capturing an Event.



Text Fields.



Text Areas.



Labels.



Check Boxes.



Radio Buttons.



Drop-down Lists.



List Boxes.



HandleEvent( ).



Controlling Layout.



FlowLayout.



BorderLayout.



GridLayout.



CardLayout.



GridBagLayout.



Alternatives to Action.



Applet Restrictions.



Applet Advantages.



Windowed Applications.



Menus.



Dialog Boxes.



The New AWT.



The New Event Model.



Event and Listener Types.



Making Windows and Applets with the Java 1.1 AWT.



Revisiting the Earlier Examples.



Binding Events Dynamically.



Separating Business Logic from UI Logic.



Recommended Coding Approaches



Java 1.1 UI APIs.



Desktop Colors.



Printing.



The Clipboard.



Visual Programming and Beans.



What is a Bean?



Extracting BeanInfo with the Introspector.



A More Sophisticated Bean.



Packaging a Bean.



More Complex Bean Support.



More to Beans.



Introduction to Swing.



Benefits of Swing.



Easy Conversion.



A Display Framework.



Tool Tips.



Borders.



Buttons.



Button Groups.



Icons.



Menus.



Popup Menus.



List Boxes and Combo Boxes.



Sliders and Progress Bars.



Trees.



Tables.



Tabbed Panes.



The Swing Message Box.



More to Swing.



Summary.



Exercises.



14. Multiple Threads.


Responsive User Interfaces.



Inheriting from Thread.



Threading for a Responsive Interface.



Combining the Thread with the Main Class.



Making Many Threads.



Daemon Threads.



Sharing Limited Resources.



Improperly Accessing Resources.



How Java Shares Resources.



Java Beans Revisited.



Blocking.



Becoming Blocked.



Deadlock.



Priorities.



Thread Groups.



Runnable Revisited.



Too Many Threads.



Summary.



Exercises.



15. Network Programming.


Identifying a Machine.



Servers and Clients.



Port: A Unique Place within the Machine.



Sockets.



A Simple Server and Client.



Serving Multiple Clients.



Datagrams.



A Web Application.



The Aerver Application.



The NameSender Applet.



Problems with this Approach.



Connecting Java to CGI.



Encoding Data for CGI.



The Applet.



The CGI Program in C++.



What about POST?



Connecting to Databases with JDBC.



Getting the Example to Work.



A GUI Version of the Lookup Program.



Why the JDBC API Seem So Complex.



Remote Methods.



Remote Interfaces.



Implementing the Remote Interface.



Creating Stubs and Skeletons.



Using the Remote Object.



Alternatives to RMI.



Summary.



Exercises.



16. Design Patterns.


The Pattern Concept.



The Singleton.



Classifying Patterns.



The Observer Pattern.



Simulating the Trash Recycler.



Improving the design.



“Make more Objects.”



A Pattern for Prototyping Creation.



Abstracting Usage.



Multiple Dispatching.



Implementing the Double Dispatch.



The “Visitor” Pattern.



RTTI Considered Harmful?



Summary.



Exercises.



17. Projects.


Text Processing.



Extracting Code Listings.



Checking Capitalization Style.



A Method Lookup Tool.



Complexity Theory.



Summary.



Exercises.



A: Using non-Java Code.


The Java.



Native Interface.



Calling a Native Method.



Accessing JNI Functions: The JNIEnv Argument.



Passing and Using Java Objects.



JNI and Java Exceptions.



JNI and Threading.



Using a Pre-existing Code Base.



The Microsoft Way.



J/Direct.



The @dll.import Directive.



The com.ms.win32 Package.



Marshaling.



Writing Callback Functions.



Other J/Direct features.



Raw Native.



Interface (RNI).



RNI Summary.



Java/COM Integration.



COM Fundamentals.



MS Java/COM Integration.



Developing COM Servers in Java.



Developing COM Clients in Java.



ActiveX/Beans integration.



A Note about Native Methods and Applets.



CORBA.



CORBA Fundamentals.



An Example.



Java Applets and CORBA.



CORBA vs. RMI.



Summary.



B. Comparing C++ and Java.


C: Java Programming Guidelines.


D: Performance.


Basic Approach.



Locating the Bottleneck.



1. Install Your Own Instrumentation.



2. JDK Profiling [2].



3. Special Tools.



Tips for Measuring Performance.



Speedup Techniques.



Generic Approaches.



Language Dependent Approaches.



Specific Situations.



References.



Performance Tools.



Web Sites.



Articles.



Java Specific Books.



General Books.



E: A bit about Garbage Collection.


F: Recommended Reading.


Index.

Erscheint lt. Verlag 13.3.1998
Verlagsort Upper Saddle River
Sprache englisch
Maße 180 x 236 mm
Gewicht 1564 g
Themenwelt Informatik Programmiersprachen / -werkzeuge Java
Mathematik / Informatik Informatik Web / Internet
ISBN-10 0-13-659723-8 / 0136597238
ISBN-13 978-0-13-659723-0 / 9780136597230
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich
mit über 150 Workouts in Java und Python

von Luigi Lo Iacono; Stephan Wiefling; Michael Schneider

Buch (2023)
Carl Hanser (Verlag)
29,99
Einführung, Ausbildung, Praxis

von Christian Ullenboom

Buch | Hardcover (2023)
Rheinwerk (Verlag)
49,90