CITATION

Sarang, Poornachandra. Java Programming. US: McGraw-Hill Osborne Media, 2012.

Java Programming

Published:  January 2012

eISBN: 9780071633611 0071633618 | ISBN: 9780071633604
  • Java™ Programming
  • About the Author
  • Contents at a Glance
  • Contents
  • Foreword
  • Acknowledgments
  • Introduction
  • Chapter 1: Introduction to Java
  • Why Java?
  • So What Is Java?
  • Java Virtual Machine
  • Features of Java
  • Small
  • Simple
  • Object Oriented
  • Compiled and Interpreted
  • Platform Independent
  • Robust and Secure
  • Multithreaded
  • Dynamic
  • Java’s Evolution
  • JDK 1.0 (January 23, 1996): Codename Oak
  • JDK 1.1 (February 19, 1997)
  • Java Beans
  • Remote Method Invocation
  • The JAR File Format
  • Digital Signatures
  • AWT Enhancements
  • Other Changes
  • J2SE 1.2 (December 8, 1998): Codename Playground
  • The Introduction of Swing
  • The 2D API
  • Drag-and-Drop
  • Audio Enhancements
  • Java IDL
  • Security Enhancements
  • Other Enhancements
  • J2SE 1.3 (May 8, 2000): Codename Kestrel
  • J2SE 1.4 (Feb 6, 2002): Codename Merlin
  • J2SE 5.0 (Sept 30, 2004): Codename Tiger
  • Java SE 6 (Dec 11, 2006): Codename Mustang
  • Java SE 7 (July 7, 2011): Codename Dolphin
  • Summary
  • Chapter 2: Arrays
  • Arrays
  • Declaring Arrays
  • Creating Arrays
  • Accessing and Modifying Array Elements
  • Initializing Arrays
  • Initializing at Runtime
  • Initializing Using Array Literals
  • The for-each Loop
  • Multidimensional Arrays
  • Two-dimensional Arrays
  • Initializing Two-dimensional Arrays
  • Initializing at Runtime
  • Initializing Using Array Literals
  • Looping Using the for-each Construct
  • N-dimensional Arrays
  • Nonrectangular Arrays
  • Runtime Initialization
  • Initialization Using Array Literals
  • A Few Goodies
  • Determining the Array Length
  • Cloning an Array
  • Finding Out the Class of an Array
  • Summary
  • Chapter 3: Classes
  • Object-Oriented Programming (OOP) Concepts
  • OOP Features
  • Encapsulation
  • Inheritance
  • Polymorphism
  • OOP Benefits
  • The Class
  • Defining a Class
  • Declaring a Point Class
  • Using Classes
  • Accessing/Modifying Fields
  • The Class Example Program
  • Declaring Methods
  • Memory Representation of Objects
  • Information Hiding
  • Encapsulation
  • Declaring Constructors
  • Default Constructor
  • Rules for Defining a Constructor
  • Source File Layout
  • The package Statement
  • The import Statement
  • Directory Layout and Packages
  • Summary
  • Chapter 4: Inheritance
  • Why Inheritance?
  • What Is Inheritance?
  • Defining Single-level Inheritance
  • Capturing Multilevel Inheritance
  • Writing a Multilevel Inheritance Program
  • Polymorphism
  • Creating a Heterogeneous Collection of Objects
  • A Program That Demonstrates a Heterogeneous Collection
  • Detecting the Object Type
  • Typecasting Rules on Inheritance Hierarchies
  • Preventing Method Overriding
  • Preventing Subclassing
  • Summary
  • Chapter 5: Object Creation and Member Visibility
  • Instantiating a Subclass
  • The Object-Creation Process
  • Calling the super Constructor
  • Method Overloading
  • Rules of Method Overloading
  • Creating a Copy Constructor
  • Invoking Constructors: Summary
  • The final Keyword
  • The final Classes
  • The final Methods
  • The final Variables
  • The final Variables of the Class Type
  • Important Points Related to the final Keyword
  • Understanding Member Visibility Rules
  • The public Modifier
  • The private Modifier
  • The protected Modifier
  • The Default Modifier
  • A Few Rules on Inheriting
  • Summary
  • Chapter 6: Static Modifier and Interfaces
  • The static Keyword
  • The Static Fields
  • Accessing Static Fields Through Object References
  • Inheriting Static Fields
  • Creating a Truly Global Variable
  • Creating Application Constants
  • Some Important Notes on Static Fields
  • The Static Methods
  • Access Restrictions in Static Methods
  • Some Important Notes on Static Methods
  • The Static Initializers
  • Advantages of a Static Initializer
  • Multiple Static Blocks
  • An Alternative to a Static Initializer
  • Some Important Notes on Static Initializers
  • Interfaces
  • A Real-life Example of an Interface
  • Understanding Interface Syntax
  • Understanding Interfaces Through an Example
  • Extending Interfaces
  • Implementing Multiple Interfaces
  • Combining Interfaces
  • A Few Important Points on Interfaces
  • Abstract Classes
  • Summary
  • Chapter 7: Nested Classes
  • Nested Classes
  • Why Use Nested Classes?
  • Classifications of Nested Classes
  • Demonstrating the Use of Inner Classes
  • Accessing an Inner Class from the Outside
  • Accessing Shadowed Variables
  • Important Points to Note
  • Member Classes
  • Local Classes
  • Defining an Inner Class within Method Scope
  • A Few Important Points on Local Classes
  • Anonymous Classes
  • Creating Anonymous Classes
  • Restrictions on the Use of Anonymous Classes
  • Compiled Anonymous Classes
  • Guidelines on Using Anonymous Classes
  • Summary
  • Chapter 8: Exception Handling
  • What Is an Exception?
  • Error Types
  • The Non-fatal Errors
  • The try-catch Statements
  • Classifying Exceptions
  • Combining Exception Handlers
  • How Runtime Matches catch Blocks
  • The finally Statement
  • Guidelines on the Use of the finally Block
  • Rules for Using the try/catch/finally Block
  • The try-with-resources Statement
  • Checked/Unchecked Exceptions
  • The throws Construct
  • Throwing Multiple Exceptions
  • User-defined Exceptions
  • The throw Statement
  • Re-throwing Exceptions
  • Difference Between the throw and throws Keywords
  • The final Re-throw in Java SE 7
  • Declaring Exceptions in Overridden Methods
  • Printing a Stack Trace
  • Asynchronous Exceptions
  • Guidelines for Using Exceptions
  • Summary
  • Chapter 9: Java I/O
  • Input/Output Streams
  • The I/O Class Hierarchy
  • The Byte Streams
  • Determining File Length
  • The InputStream Methods
  • The OutputStream Class
  • File Copy Utility
  • The OutputStream Methods
  • Character Streams
  • File Viewer Utility
  • Buffered Readers/Writers
  • The BufferedReader Class
  • The BufferedWriter Class
  • Binary Versus Character Streams
  • Chaining Streams
  • The Line Count Program
  • File Concatenation
  • Accessing the Host File System
  • The Directory Listing Program
  • Filtering the Directory Listing
  • Reading/Writing Objects
  • Summary
  • Chapter 10: Advanced I/O
  • The Byte-Oriented Stream Classes
  • The PushbackInputStream Class
  • The SequenceInputStream Class
  • The PrintStream Class
  • The Character-Oriented Stream Classes
  • The CharArray Reader/Writer Classes
  • The Console Class
  • The StreamTokenizer Class
  • The Object-Oriented Streams
  • The Externalizable Interface
  • Nested Objects Serialization
  • Versioning Objects
  • Summary
  • Chapter 11: Enums, Autoboxing, and Annotations
  • Typesafe Enumerations
  • Creating Integer Patterns for Enumerations
  • The enum Type
  • Listing Enumeration Constants
  • Adding Properties to an Enumeration
  • The ordinal and compareTo Methods
  • Attaching Methods to Enumerations
  • Serializing enum Types
  • Autoboxing
  • Wrapper Classes
  • A Few Additions in J2SE 5.0
  • Additional Functionality
  • Extended Support for Unicode Code Point
  • The Void Wrapper
  • Autoboxing/Unboxing
  • Annotations
  • Built-in Annotations
  • The @Override Annotation
  • The @SuppressWarnings Annotation
  • Declaring Annotations
  • Marker Annotations
  • Multivalue Annotations
  • Custom Annotation Program
  • Rules for Defining Annotation Types
  • Annotating an Annotation
  • The Target Annotation
  • The Retention Annotation
  • Annotations at Runtime
  • The Documented Annotation
  • The Inherited Annotation
  • Summary
  • Chapter 12: Generics
  • Generics
  • What Are Generics?
  • Why Do We Need Generics?
  • A Sample Generics Program
  • Type Safety
  • Creating a Parameterized Stack Type
  • Declaration Syntax
  • A Generic Stack Class
  • Examining Intermediate Code
  • Testing the Stack Class
  • Bounded Types
  • Using Wildcards
  • Bounded Wildcards
  • Raw Types
  • More on Generic Types
  • Class with Two Generic Parameters
  • Casting Types
  • Comparing and Assigning Generic Types
  • Generic Methods
  • Declaring Generic Interfaces
  • Restrictions in Generics
  • Creating Arrays
  • Instantiating Type Parameters
  • Use of the static Keyword
  • Summary
  • Chapter 13: Event Processing and GUI Building
  • Event Processing Model
  • Delegation Event Model
  • The Event Source
  • The Event Listener
  • Event Processing Sequence
  • Registering on Multiple Event Sources
  • Multiple Event Types
  • Building a GUI
  • Creating the User Interface
  • Demonstrating the Button Control
  • Demonstrating the Edit Control
  • Demonstrating the List Box Control
  • Summary
  • Chapter 14: Creating Layouts
  • Layout Managers
  • Types of Layout Managers
  • Building the GUI
  • How Do Layout Managers Work?
  • Using Layout Managers
  • BorderLayout
  • Using NetBeans to Build the GUI
  • FlowLayout
  • CardLayout
  • GridLayout
  • GridBagLayout
  • BoxLayout
  • Tabbed Dialog Box
  • Advanced Layout Managers
  • Summary
  • Chapter 15: Graphics and User Gestures Processing
  • What Is an Applet?
  • Creating Your First Applet
  • Running the Applet
  • Using AppletViewer
  • Understanding Applet Life-cycle Methods
  • Processing Mouse Events
  • Mouse Clicks
  • Mouse Motion Events
  • Creating Popup Menus
  • Customizing the Drawing Color
  • Processing Keyboard Events
  • Summary
  • Chapter 16: Collections
  • What Is the Java Collections Framework?
  • Benefits of the Collections Framework
  • What the Collections Framework Offers
  • The Collections Framework Interfaces
  • The Collections Framework Classes
  • List
  • Optional Operations of the List Interface
  • Set
  • HashSet
  • TreeSet
  • Queue
  • Map
  • Algorithms
  • Summary
  • Chapter 17: Threads
  • Processes and Threads
  • Thread States
  • Thread Priorities
  • Thread Scheduling
  • JVM Threading Implementations
  • Green Threads
  • Windows Implementation
  • Solaris Implementation
  • Linux Implementation
  • Daemon Versus Non-Daemon Threads
  • Creating Threads
  • Creating Your First Threaded Application
  • Creating Non-Daemon Threads
  • Thread Class Constructors
  • Static Methods of Thread
  • Some Essential Operations on Thread
  • Setting the Daemon Property
  • Starting the Thread
  • Stop, Suspend, and Resume Operations
  • Yielding Control
  • Setting the Priority
  • Waiting on Other Objects
  • Interrupting Threads
  • Joining
  • Thread Synchronization
  • Bucket Transfers
  • Producer/Consumer Problem
  • Object Locks
  • When to Synchronize
  • The Deadlock
  • Solutions to Deadlock
  • Lock Ordering
  • Lock Timeout
  • Deadlock Detection
  • Summary
  • Chapter 18: Blocking Queues and Synchronizers
  • Blocking Queues
  • Characteristics of Blocking Queues
  • The BlockingQueue Interface
  • Implementations of the BlockingQueue Interface
  • ArrayBlockingQueue
  • LinkedBlockingQueue
  • PriorityBlockingQueue
  • DelayedQueue
  • SynchronousQueue
  • TransferQueue
  • Stock-trading System
  • The LinkedTransferQueue Example
  • Synchronizers
  • Semaphores
  • Barriers
  • Countdown Latches
  • Phaser
  • Exchangers
  • Summary
  • Chapter 19: Callables, Futures, Executors, and Fork/Join
  • Callables and Futures
  • The Callable Interface
  • The Future Interface
  • How Callable and Future Work
  • Using Callables in Parallelizing Large Tasks
  • The FutureTask Class
  • Creating Cancellable Tasks
  • Executors
  • Creating a Thread Pool for Scheduled Executions
  • The ScheduledExecutorService Class
  • Demonstrating Scheduled Task Execution
  • Obtaining the Results of the First Completed Execution
  • Demonstrating the ExecutorCompletionService Class
  • Fork/Join Framework
  • The ForkJoinPool Class
  • The ForkJoinTask Class
  • Sorting an Enormous Array of Floats
  • Thread-safe Collections
  • The ThreadLocalRandom Class
  • Summary
  • Chapter 20: Network Programming
  • Networking
  • Simple Home Page Reader
  • The URL Class
  • The URLConnection Class
  • Webpage Reader
  • The HttpCookie Class
  • Spying for Cookies
  • Echo Server Application
  • Testing the Echo Server Application
  • Serving Multiple Clients
  • Serving Simultaneous Clients
  • Running the EchoMultiServer Application
  • Testing the EchoMultiServer Application
  • Writing a File Storage Server Application
  • A Cloud Storage Server
  • A Cloud Store Client
  • Testing the File Upload/Download Utility
  • The InetAddress Class
  • Broadcasting Messages
  • Writing a Stock Quotes Server
  • Writing the Stock Trader Client
  • Running the Server and Client
  • Support for SCTP
  • Summary
  • Chapter 21: Utility Classes
  • The String Class
  • A Few Important Methods
  • Practical Demonstration of String Methods
  • Comparing Strings
  • Creating Formatted Output
  • The Calendar Class
  • The GregorianCalendar Methods
  • The Local Time Converter Application
  • Introspection and Reflection
  • The Class Class
  • The Method Class
  • The Class Browser Application
  • The Introspection Test Application
  • The Class Browser
  • Disadvantages
  • What’s Next?
  • Summary
  • Index