Java: The Complete Reference, Eleventh Edition, 11th Edition
Read it now on the O’Reilly learning platform with a 10-day free trial.
O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.
Book description
The Definitive Java Programming Guide
Fully updated for Java SE 11, Java: The Complete Reference, Eleventh Edition explains how to develop, compile, debug, and run Java programs. Best-selling programming author Herb Schildt covers the entire Java language, including its syntax, keywords, and fundamental programming principles. You’ll also find information on key portions of the Java API library, such as I/O, the Collections Framework, the stream library, and the concurrency utilities. Swing, JavaBeans, and servlets are examined and numerous examples demonstrate Java in action. Of course, the very important module system is discussed in detail. This Oracle Press resource also offers an introduction to JShell, Java’s interactive programming tool. Best of all, the book is written in the clear, crisp, uncompromising style that has made Schildt the choice of millions worldwide.
Coverage includes:
•Data types, variables, arrays, and operators
•Control statements
•Classes, objects, and methods
•Method overloading and overriding
•Inheritance
•Local variable type inference
•Interfaces and packages
•Exception handling
•Multithreaded programming
•Enumerations, autoboxing, and annotations
•The I/O classes
•Lambda expressions
•String handling
•The Collections Framework
•Networking
•Event handling
•The Concurrent API
•The Stream API
•Regular expressions
•Much, much more
Code examples in the book are available for download at www.OraclePressBooks.com.
Show and hide more
Table of contents Product information
Table of contents
- Cover
- Title Page
- Copyright Page
- Contents at a Glance
- Contents
- Preface
- Part I The Java Language
- Chapter 1 The History and Evolution of Java
- Java’s Lineage
- The Birth of Modern Programming: C
- C++: The Next Step
- The Stage Is Set for Java
- The C# Connection
- Java Applets
- Security
- Portability
- Simple
- Object-Oriented
- Robust
- Multithreaded
- Architecture-Neutral
- Interpreted and High Performance
- Distributed
- Dynamic
- Object-Oriented Programming
- Two Paradigms
- Abstraction
- The Three OOP Principles
- Entering the Program
- Compiling the Program
- A Closer Look at the First Sample Program
- The if Statement
- The for Loop
- Whitespace
- Identifiers
- Literals
- Comments
- Separators
- The Java Keywords
- Java Is a Strongly Typed Language
- The Primitive Types
- Integers
- byte
- short
- int
- long
- float
- double
- Integer Literals
- Floating-Point Literals
- Boolean Literals
- Character Literals
- String Literals
- Declaring a Variable
- Dynamic Initialization
- The Scope and Lifetime of Variables
- Java’s Automatic Conversions
- Casting Incompatible Types
- The Type Promotion Rules
- One-Dimensional Arrays
- Multidimensional Arrays
- Alternative Array Declaration Syntax
- Some var Restrictions
- Arithmetic Operators
- The Basic Arithmetic Operators
- The Modulus Operator
- Arithmetic Compound Assignment Operators
- Increment and Decrement
- The Bitwise Logical Operators
- The Left Shift
- The Right Shift
- The Unsigned Right Shift
- Bitwise Operator Compound Assignments
- Short-Circuit Logical Operators
- Java’s Selection Statements
- if
- switch
- while
- do-while
- for
- The For-Each Version of the for Loop
- Local Variable Type Inference in a for Loop
- Nested Loops
- Using break
- Using continue
- Class Fundamentals
- The General Form of a Class
- A Simple Class
- A Closer Look at new
- Adding a Method to the Box Class
- Returning a Value
- Adding a Method That Takes Parameters
- Parameterized Constructors
- Instance Variable Hiding
- Overloading Methods
- Overloading Constructors
- Overloading Vararg Methods
- Varargs and Ambiguity
- Inheritance Basics
- Member Access and Inheritance
- A More Practical Example
- A Superclass Variable Can Reference a Subclass Object
- Using super to Call Superclass Constructors
- A Second Use for super
- Why Overridden Methods?
- Applying Method Overriding
- Using final to Prevent Overriding
- Using final to Prevent Inheritance
- Packages
- Defining a Package
- Finding Packages and CLASSPATH
- A Short Package Example
- An Access Example
- Defining an Interface
- Implementing Interfaces
- Nested Interfaces
- Applying Interfaces
- Variables in Interfaces
- Interfaces Can Be Extended
- Default Method Fundamentals
- A More Practical Example
- Multiple Inheritance Issues
- Exception-Handling Fundamentals
- Exception Types
- Uncaught Exceptions
- Using try and catch
- Displaying a Description of an Exception
- The Java Thread Model
- Thread Priorities
- Synchronization
- Messaging
- The Thread Class and the Runnable Interface
- Implementing Runnable
- Extending Thread
- Choosing an Approach
- Using Synchronized Methods
- The synchronized Statement
- Deadlock
- Enumerations
- Enumeration Fundamentals
- The values( ) and valueOf( ) Methods
- Java Enumerations Are Class Types
- Enumerations Inherit Enum
- Another Enumeration Example
- Character
- Boolean
- The Numeric Type Wrappers
- Autoboxing and Methods
- Autoboxing/Unboxing Occurs in Expressions
- Autoboxing/Unboxing Boolean and Character Values
- Autoboxing/Unboxing Helps Prevent Errors
- A Word of Warning
- Annotation Basics
- Specifying a Retention Policy
- Obtaining Annotations at Run Time by Use of Reflection
- The AnnotatedElement Interface
- Using Default Values
- Marker Annotations
- Single-Member Annotations
- The Built-In Annotations
- I/O Basics
- Streams
- Byte Streams and Character Streams
- The Predefined Streams
- Reading Characters
- Reading Strings
- Assertion Enabling and Disabling Options
- What Are Generics?
- A Simple Generics Example
- Generics Work Only with Reference Types
- Generic Types Differ Based on Their Type Arguments
- How Generics Improve Type Safety
- Bounded Wildcards
- Generic Constructors
- Using a Generic Superclass
- A Generic Subclass
- Run-Time Type Comparisons Within a Generic Hierarchy
- Casting
- Overriding Methods in a Generic Class
- Bridge Methods
- Type Parameters Can’t Be Instantiated
- Restrictions on Static Members
- Generic Array Restrictions
- Generic Exception Restriction
- Introducing Lambda Expressions
- Lambda Expression Fundamentals
- Functional Interfaces
- Some Lambda Expression Examples
- Method References to static Methods
- Method References to Instance Methods
- Method References with Generics
- Module Basics
- A Simple Module Example
- Compile and Run the First Module Example
- A Closer Look at requires and exports
- Service and Service Provider Basics
- The Service-Based Keywords
- A Module-Based Service Example
- Open Modules
- The opens Statement
- requires static
- Linking Files in an Exploded Directory
- Linking Modular JAR Files
- JMOD Files
- Chapter 17 String Handling
- The String Constructors
- String Length
- Special String Operations
- String Literals
- String Concatenation
- String Concatenation with Other Data Types
- String Conversion and toString( )
- charAt( )
- getChars( )
- getBytes( )
- toCharArray( )
- equals( ) and equalsIgnoreCase( )
- regionMatches( )
- startsWith( ) and endsWith( )
- equals( ) Versus ==
- compareTo( )
- substring( )
- concat( )
- replace( )
- trim( ) and strip( )
- StringBuffer Constructors
- length( ) and capacity( )
- ensureCapacity( )
- setLength( )
- charAt( ) and setCharAt( )
- getChars( )
- append( )
- insert( )
- reverse( )
- delete( ) and deleteCharAt( )
- replace( )
- substring( )
- Additional StringBuffer Methods
- Primitive Type Wrappers
- Number
- Double and Float
- Understanding isInfinite( ) and isNaN( )
- Byte, Short, Integer, and Long
- Character
- Additions to Character for Unicode Code Point Support
- Boolean
- Memory Management
- Executing Other Programs
- Using currentTimeMillis( ) to Time Program Execution
- Using arraycopy( )
- Environment Properties
- Trigonometric Functions
- Exponential Functions
- Rounding Functions
- Miscellaneous Math Methods
- The Runnable Interface
- Thread
- ThreadGroup
- java.lang.annotation
- java.lang.instrument
- java.lang.invoke
- java.lang.management
- java.lang.module
- java.lang.ref
- java.lang.reflect
- Collections Overview
- The Collection Interfaces
- The Collection Interface
- The List Interface
- The Set Interface
- The SortedSet Interface
- The NavigableSet Interface
- The Queue Interface
- The Deque Interface
- The ArrayList Class
- The LinkedList Class
- The HashSet Class
- The LinkedHashSet Class
- The TreeSet Class
- The PriorityQueue Class
- The ArrayDeque Class
- The EnumSet Class
- Using an Iterator
- The For-Each Alternative to Iterators
- The Map Interfaces
- The Map Classes
- Using a Comparator
- The Enumeration Interface
- Vector
- Stack
- Dictionary
- Hashtable
- Properties
- Using store( ) and load( )
- StringTokenizer
- BitSet
- Optional, OptionalDouble, OptionalInt, and OptionalLong
- Date
- Calendar
- GregorianCalendar
- TimeZone
- SimpleTimeZone
- Locale
- Random
- Timer and TimerTask
- Currency
- Formatter
- The Formatter Constructors
- The Formatter Methods
- Formatting Basics
- Formatting Strings and Characters
- Formatting Numbers
- Formatting Time and Date
- The %n and %% Specifiers
- Specifying a Minimum Field Width
- Specifying Precision
- Using the Format Flags
- Justifying Output
- The Space, +, 0, and ( Flags
- The Comma Flag
- The # Flag
- The Uppercase Option
- Using an Argument Index
- Closing a Formatter
- The Java printf( ) Connection
- The Scanner Constructors
- Scanning Basics
- Some Scanner Examples
- Setting Delimiters
- Other Scanner Features
- java.util.concurrent, java.util.concurrent.atomic, and java.util.concurrent.locks
- java.util.function
- java.util.jar
- java.util.logging
- java.util.prefs
- java.util.regex
- java.util.spi
- java.util.stream
- java.util.zip
- The I/O Classes and Interfaces
- File
- Directories
- Using FilenameFilter
- The listFiles( ) Alternative
- Creating Directories
- InputStream
- OutputStream
- FileInputStream
- FileOutputStream
- ByteArrayInputStream
- ByteArrayOutputStream
- Filtered Byte Streams
- Buffered Byte Streams
- SequenceInputStream
- PrintStream
- DataOutputStream and DataInputStream
- RandomAccessFile
- Reader
- Writer
- FileReader
- FileWriter
- CharArrayReader
- CharArrayWriter
- BufferedReader
- BufferedWriter
- PushbackReader
- PrintWriter
- Serializable
- Externalizable
- ObjectOutput
- ObjectOutputStream
- ObjectInput
- ObjectInputStream
- A Serialization Example
- The NIO Classes
- NIO Fundamentals
- Buffers
- Channels
- Charsets and Selectors
- The Path Interface
- The Files Class
- The Paths Class
- The File Attribute Interfaces
- The FileSystem, FileSystems, and FileStore Classes
- Use NIO for Channel-Based I/O
- Use NIO for Stream-Based I/O
- Use NIO for Path and File System Operations
- Networking Basics
- The java.net Networking Classes and Interfaces
- InetAddress
- Factory Methods
- Instance Methods
- DatagramSocket
- DatagramPacket
- A Datagram Example
- Three Key Elements
- A Simple HTTP Client Example
- Things to Explore in java.net.http
- Two Event Handling Mechanisms
- The Delegation Event Model
- Events
- Event Sources
- Event Listeners
- The ActionEvent Class
- The AdjustmentEvent Class
- The ComponentEvent Class
- The ContainerEvent Class
- The FocusEvent Class
- The InputEvent Class
- The ItemEvent Class
- The MouseEvent Class
- The MouseWheelEvent Class
- The TextEvent Class
- The WindowEvent Class
- The ActionListener Interface
- The AdjustmentListener Interface
- The ComponentListener Interface
- The ContainerListener Interface
- The FocusListener Interface
- The ItemListener Interface
- The KeyListener Interface
- The MouseListener Interface
- The MouseMotionListener Interface
- The MouseWheelListener Interface
- The TextListener Interface
- The WindowFocusListener Interface
- The WindowListener Interface
- Some Key AWT GUI Concepts
- Handling Mouse Events
- Handling Keyboard Events
- Anonymous Inner Classes
- AWT Classes
- Window Fundamentals
- Component
- Container
- Panel
- Window
- Frame
- Canvas
- Setting the Window’s Dimensions
- Hiding and Showing a Window
- Setting a Window’s Title
- Closing a Frame Window
- The paint( ) Method
- Displaying a String
- Setting the Foreground and Background Colors
- Requesting Repainting
- Creating a Frame-Based Application
- Drawing Lines
- Drawing Rectangles
- Drawing Ellipses and Circles
- Drawing Arcs
- Drawing Polygons
- Demonstrating the Drawing Methods
- Sizing Graphics
- Color Methods
- Setting the Current Graphics Color
- A Color Demonstration Program
- Determining the Available Fonts
- Creating and Selecting a Font
- Obtaining Font Information
- AWT Control Fundamentals
- Adding and Removing Controls
- Responding to Controls
- The HeadlessException
- Handling Buttons
- Handling Check Boxes
- Handling Choice Lists
- Handling Lists
- Handling Scroll Bars
- Handling a TextField
- FlowLayout
- BorderLayout
- Using Insets
- GridLayout
- CardLayout
- GridBagLayout
- File Formats
- Image Fundamentals: Creating, Loading, and Displaying
- Creating an Image Object
- Loading an Image
- Displaying an Image
- MemoryImageSource
- PixelGrabber
- CropImageFilter
- RGBImageFilter
- The Concurrent API Packages
- java.util.concurrent
- java.util.concurrent.atomic
- java.util.concurrent.locks
- Semaphore
- CountDownLatch
- CyclicBarrier
- Exchanger
- Phaser
- A Simple Executor Example
- Using Callable and Future
- The Main Fork/Join Classes
- The Divide-and-Conquer Strategy
- A Simple First Fork/Join Example
- Understanding the Impact of the Level of Parallelism
- An Example that Uses RecursiveTask
- Executing a Task Asynchronously
- Cancelling a Task
- Determining a Task’s Completion Status
- Restarting a Task
- Things to Explore
- Some Fork/Join Tips
- Stream Basics
- Stream Interfaces
- How to Obtain a Stream
- A Simple Stream Example
- Use an Iterator with a Stream
- Use Spliterator
- Regular Expression Processing
- Pattern
- Matcher
- Regular Expression Syntax
- Demonstrating Pattern Matching
- Two Pattern-Matching Options
- Exploring Regular Expressions
- A Simple Client/Server Application Using RMI
- DateFormat Class
- SimpleDateFormat Class
- Time and Date Fundamentals
- Formatting Date and Time
- Parsing Date and Time Strings
- Other Things to Explore in java.time
- Chapter 31 Introducing Swing
- The Origins of Swing
- Swing Is Built on the AWT
- Two Key Swing Features
- Swing Components Are Lightweight
- Swing Supports a Pluggable Look and Feel
- Components
- Containers
- The Top-Level Container Panes
- Painting Fundamentals
- Compute the Paintable Area
- A Paint Example
- JLabel and ImageIcon
- JTextField
- The Swing Buttons
- JButton
- JToggleButton
- Check Boxes
- Radio Buttons
- Menu Basics
- An Overview of JMenuBar, JMenu, and JMenuItem
- JMenuBar
- JMenu
- JMenuItem
- Chapter 34 Java Beans
- What Is a Java Bean?
- Advantages of Beans
- Introspection
- Design Patterns for Properties
- Design Patterns for Events
- Methods and Design Patterns
- Using the BeanInfo Interface
- Introspector
- PropertyDescriptor
- EventSetDescriptor
- MethodDescriptor
- Background
- The Life Cycle of a Servlet
- Servlet Development Options
- Using Tomcat
- A Simple Servlet
- Create and Compile the Servlet Source Code
- Start Tomcat
- Start a Web Browser and Request the Servlet
- The Servlet Interface
- The ServletConfig Interface
- The ServletContext Interface
- The ServletRequest Interface
- The ServletResponse Interface
- The GenericServlet Class
- The ServletInputStream Class
- The ServletOutputStream Class
- The Servlet Exception Classes
- The HttpServletRequest Interface
- The HttpServletResponse Interface
- The HttpSession Interface
- The Cookie Class
- The HttpServlet Class
- Handling HTTP GET Requests
- Handling HTTP POST Requests
- Appendix A Using Java’s Documentation Comments
- The javadoc Tags
- @author
- @deprecated
- @exception
- @hidden
- @param
- @provides
- @return
- @see
- @serial
- @serialData
- @serialField
- @since
- @throws
- @uses
- @version
- JShell Basics
- List, Edit, and Rerun Code
- Add a Method
- Create a Class
- Use an Interface
- Evaluate Expressions and Use Built-in Variables
- Importing Packages
- Exceptions
- Some More JShell Commands
- Exploring JShell Further
Show and hide more
Product information
- Title: Java: The Complete Reference, Eleventh Edition, 11th Edition
- Author(s): Herbert Schildt
- Release date: December 2018
- Publisher(s): McGraw-Hill
- ISBN: 9781260440249