Java 2 By Example - Jerry Jackson, Alan McClellan

Java 2 By Example

Media-Kombination
544 Seiten
1998 | 3rd edition
Prentice Hall
978-0-13-079669-1 (ISBN)
49,95 inkl. MwSt
  • Titel ist leider vergriffen;
    keine Neuauflage
  • Artikel merken
Java by Example, Third Edition is designed to help programmers learn from proven examples. Review real, working code, and learn the right way to develop Java applets and applications. This book has been completely updated to cover JDK 1.2 with in-depth coverage of inner classes, reflection and collection classes.
Java by Example, Third Edition is designed to help programmers learn from proven examples written by experts. Review real, working code, and learn the right way to develop Java applets and applications that are elegant, readable, and easy to maintain. The book has been completely updated to cover JDK 1.2, with in-depth coverage of inner classes, reflection and collection classes. It covers a wide variety of JDK 1.2 inner class mechanisms, helping you choose the most powerful, flexible approaches to structuring your applications. It presents detailed coverage of JDK 1.2 reflection capabilities, showing when to use them - and when not to. Learn better techniques for managing memory, working constructors, I/O, multithreading, exception handling, security, networking, JDBC database access, and more.

Jerry R. Jackson, formerly a staff engineer at Sun Microsystems, Inc. in Colorado Springs, Colorado, has over ten years experience with object-oriented technology and is currently developing Java applications for Channel Point, Inc. Alan L. McClellan, an award-winning software technical writer, co-authored Graphic Java: Mastering the AWT, and is series editor for Prentice Hall PTR's Essential Series (Essential JNI, Essential JTAPI, Essential JMF).

List of Tables


List of Examples


List of Figures


Preface


Why We Are Here


Audience


For Mac Programmers


For C Programmers


Internet Sources of Information


Conventions Used in This Book


Applets Applications and Programming Aids


Java by Example CD Contents


Acknowledgments
I. - WORKING WITH THE JAVA LANGUAGE

1. ABOUT JAVA.


What Is Java? Java and the World-Wide Web. The Java Utilities You Need to Know About. The Java Interpreter and Java Runtime Environment. The Java Compiler. The Appletviewer Program. CLASSPATH. Javadoc. Applications and Applets. Writing Compiling and Running an Application. Writing Compiling and Viewing an Applet. Incorporating Applets Into a Web Page. Summary.

2. Beginning With a Program.


A Line Counter Program. A Closer Look at the Line Counter. Output From the Line Counter. Summary.

3. The Java Language Structure.


Introduction. Classes and Methods. Instance Methods. Class Methods. The main() Method. Overriding Methods. Abstract Methods. Native Methods. Final Methods. Method Modifiers and Their Scope. Scope of a public Method. Scope of a private Method. Scope of a friendly Method. Scope of a protected Method. Variables. Variable Type. Variable Modifiers. Variable Scope and Extent. Instance Variables. Class Variables. Local Variables. Constants. Variables Methods and Superclasses. Static Initializers. Packages and the import Statement. Summary.

4. Memory and Constructors.


Dynamic Allocation and Garbage Collection. The new Operator and Constructors. Using Multiple Constructors Within a Class. The Default Constructor. Using super and this in Constructors. Finalization. A Sample Program Showing Linked Lists in Java. The LongMult Class and the main() Method. The BigNum Class. The NumNode and BigNumFormatException Classes. Output From the Long Multiplier Program. Summary.

5. Interfaces as Types.


What Is an Interface? Why Use an Interface? Using Interfaces. Extending Interfaces. A Sample Program Using Interfaces. The TreeSort Class and the main() Method. The Tree Class. The TreeNode Class. The InorderEnumeration Class. The TreeKey Interface. Output From the Tree Sort Program. Summary.

6. Arrays.


Basics of Java Arrays. Arrays of Objects. Multidimensional Arrays. C++ Style Array Initialization. Array Expressions. Alternative Array Declaration Syntax. Arrays in the Object Hierarchy. Summary.

7. Exception Handling.


Exceptional Conditions. Problems Using Return Codes for Error Processing. Catching and Throwing Exceptions. try and catch. The finally Statement. The throw Statement. Errors. Declaring Exceptions. Runtime Exceptions. Remote Exceptions. Summary.

8. Input/Output.


Introduction. Java I/O Classes and Wrappers. Standard Streams for a Java Program. Printing Text Output in Java. Reading Text Input in Java. Reading Characters. Reading an Array of Bytes. Output of the CopyFile Program. Reading Text a Line at a Time. Output of the CopyTextFile Program. Reading a Token at a Time. Output of the TokenizerText Program. File Input and Output in Java. Output of the AppendTextFile Program. Data Input and Output in Java. Summary.

9. Runtime Typing and Class Loading.


Introduction. Variable Types and Their Values. The instanceof Operator. Type Casting. Class Loading at Runtime. Class Loaders. Summary.

10. Linking With Native Code.


Introduction. Why Link With Native Code? Using JNI. Declaring Native Methods. Generating Include Files. Building a Library. Linking a Library into Java. JNI Native Methods and the Java Virtual Machine. Using the JNI for a Symbol Lookup. Using the Native Method Interface for Symbol Lookup. Generating Include Files. Generating Stub Functions. Using the Native Method Interface Example One. Using the Native Method Interface Example Two. Using the Native Method Interface Example Three. Summary.

11. Multiple Threads of Execution.


Introduction. Creating Threads. Extending the Thread Class. Implementing the Runnable Interface. Resource Locking. Using the synchronized Modifier. Using synchronized Blocks. Summary.

12. Inner Classes.


Member Classes. Local Classes. Anonymous Classes. Scoping and Inner Classes. Scoping and Member Classes. Static Member Classes. Anonymous Classes and Higher-Order Programming. An Extended Example: Anonymous Classes Closures and Continuation Passing Style. Closure Interface. Predicate Interface. Match Class. MatchExp Class. AnyExp Class. PairExp Class. VarExp Class. SeqVarExp Class. ListExp Class. SeqClosure Interface. BindingMap Class. Cell Class. NoSuchBindingException Class. LispCons Class. LetSpecialForm Class. Summary.

13. Collection Classes.


Standard Data Structures. Java Collection Classes Hierarchy. The Collection Interface Hierarchy. The Map Interface Hierarchy. The Collection Class Hierarchy. Operations on Collections. Operations on Maps. Subinterfaces of Collection and Map. List. Set. SortedSet. SortedMap. Tips. The WeakHashMap Class. Using Collections-Large Strings. Collections Package Classes. The CharList Class. UniqueCharList Class. Canonicalizer Class. Summary.

14. Reflection.


From Whence It Came. Uses of Reflection. When Not to Use Reflection. The java.lang.Class Class and the java.lang.reflect Package. Reflection and Primitive Types. Reflective Class Operations in Java. An Interpreter Written in Java. Refection at Work. The lisp Reflector Class. The lisp.prim.LispAFetchFun Class. The lisp.prim.LispAStoreFun Class. Sample Session. Summary.

15. Putting the Language Pieces Together.


Four-Function Calculator. The Calculator main() Method. The Calculator Class. The CalcInput Class. The ExitException Class. Displayable Interface. The Processable Interface. The ProcessableCharacter Class. The ProcessableDouble Class. The CalcStack Class. The CalcStackItem Interface. Running the Calculator Program. Summary.

16. Remote Method Invocation.


What is Remote Method Invocation? How RMI Works. Calling Remote Methods. The RemOp Interface. The RemImpl Class. Running the rmi1 Example. Building RMI Applications. Defining Interfaces. Creating Classes That Implement the Interfaces. Creating Stub and Skeleton Classes. Passing Arguments to Remote Methods. The Action Interface. The ServerAction Class. The ClientAction Interface. The RemoteCaller Interface. The RemoteCallerImpl Class. The ClientActionImpl Class. Running the rmi2 Example. Managing Multiple RMI Client Processes. The ActionTestSet Class. The ClientActionImpl Class. The RemoteCaller Interface. The RemoteCallerImpl Class. Running the rmi3 Example. RMI and Threads. The ActionTestSet Class. The ClientActionImpl Class. Running the rmi4 Example. Registries. Finding Objects in a Registry. Changing the Contents of a Registry. Garbage Collection of Remote References. Maintaining Object References Across Multiple Processes. The Builder Interface. The BuildImp Class. The RemNode Interface. The NodeImpl Class. Running the rmi5 Example. Summary.

17. Java Database Connectivity.


What is Java Database Connectivity? Structure of a JDBC Application. Database Connections. Interacting With a Database. SQL/Java Type Correspondence. Executing Precompiled SQL. Generic get and set Methods. Resources. Metadata. Transactions. Cursors. Exercising the JDBC. Summary.

II. - WRITING JAVA APPLETS

18. INTRODUCTION TO APPLETS.


Introduction. Java's Applet Tools and Class Support. Displaying Applet Output. A Simple Applet. Configurable Applets. Displaying a Static Label. Output From the Static Label Applet. Incorporating Images and Sound. Output From the ImageWithSound Applet. Active Applets. Displaying a Flashing Label. Output From the Flashing Label Applet. Summary.

19. Forms in Applets.


Introduction. Containers. Layout Managers. A Forms-based Applet. Output from the Occupational Oracle Applet. Summary.

20. Animation in Applets.


Incorporating Animation. A Ticker-tape Applet. Output From the Ticker-tape Applet. Summary.

21. Events and Threads in Applets.


Introduction. Simple Event Handling. Puzzle Applet. Output From the Puzzle Applet. Managing Events and Threads. Memory Game Applet. Output From the Memory Game Applet. Summary.

22. Putting the Applet Pieces Together.


Introduction. Constructing the Cellular Applet. Applet Overview. Operation of the Applet. Use of synchronized in the Applet. A Custom Layout Manager. Defining Rules. Scripting the Applet. Applet Class Structure. The Cellular Applet. The BoardLayout Class. The Arena Class. The Rules Class. Summary.

III. - APPENDIXES

APPENDIX A OBJECT-ORIENTED PROGRAMMING.


Overview. Classes. Instances. Inheritance. Encapsulation. Overloading. Polymorphism.

Appendix B: Quick Reference.


Java for C Programmers. Java for C++ Programmers. Data Types. Operators. Control Flow and Iteration. Comments. Keywords. Deprecated APIs. The Java Classes and Interfaces. The HTML applet and param Tags.

Index.

Erscheint lt. Verlag 23.12.1998
Verlagsort Upper Saddle River
Sprache englisch
Maße 179 x 235 mm
Gewicht 1178 g
Themenwelt Informatik Programmiersprachen / -werkzeuge Java
Mathematik / Informatik Informatik Web / Internet
ISBN-10 0-13-079669-7 / 0130796697
ISBN-13 978-0-13-079669-1 / 9780130796691
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich