Java The Complete Reference Notes
Java The Complete Reference Notes
The C# Connection
Java Applets
Security
Portability
Object-Oriented
Robust
Multithreaded
Architecture-Neutral
Distributed
Dynamic
A Culture of Innovation
Object-Oriented Programming
Two Paradigms
Abstraction
The if Statement
Lexical Issues
Whitespace
Literals
Comments
Separators
Integers
Byte
short
int
long
Floating-Point Types
Float
Characters
Booleans
Integer Literals
Floating-Point Literals
Boolean Literals
Character Literals
String Literals
Variables
Declaring a Variable
Dynamic Initialization
Arrays
One-Dimensional Arrays
Multidimensional Arrays
Chapter # 4 Operators
Arithmetic Operators
Relational Operators
The ? Operator
Operator Precedence
Using Parentheses
If
switch
Iteration Statements
While
do-while
for
Nested Loops
Jump Statements
Using break
Using continue
Class Fundamentals
A Simple Class
Declaring Objects
Introducing Methods
Returning a Value
Constructors
Parameterized Constructors
Garbage Collection
A Stack Class
Overloading Methods
Overloading Constructors
Returning Objects
Recursion
Understanding static
Introducing final
Arrays Revisited
Chapter # 8 Inheritance
Inheritance Basics
Using super
Method Overriding
Packages
Defining a Package
An Access Example
Importing Packages
Interfaces
Defining an Interface
Implementing Interfaces
Nested Interfaces
Applying Interfaces
Variables in Interfaces
Exception-Handling Fundamentals
Exception Types
Uncaught Exceptions
Throw
throws
finally
Chained Exceptions
Using Exceptions
Thread Priorities
Synchronization
Messaging
Creating a Thread
Implementing Runnable
Choosing an Approach
Thread Priorities
Synchronization
Interthread Communication
Deadlock
Using Multithreading
Enumerations
Enumeration Fundamentals
Type Wrappers
Character
Boolean
Autoboxing
A Word of Warning
Annotations
Marker Annotations
Single-Member Annotations
Type Annotations
Repeating Annotations
Some Restrictions
I/O Basics
Streams
Reading Characters
Reading Strings
Using instanceof
Strictfp
Native Methods
Using assert
Static Import
Chapter # 14 Generics
Bounded Types
Bounded Wildcards
Generic Constructors
Generic Interfaces
A Generic Subclass
Casting
Erasure
Bridge Methods
Ambiguity Errors
Functional Interfaces
Method References
Constructor References
Chapter # 16 Modules
Module Basics
Use Services
Module Graphs
Open Modules
requires static
JMOD Files
String Length
String Literals
String Concatenation
Character Extraction
charAt( )
getChars( )
getBytes( )
toCharArray( )
String Comparison
regionMatches( )
equals( ) Versus ==
compareTo( )
Searching Strings
Modifying a String
substring( )
concat( )
replace( )
Joining Strings
StringBuffer
StringBuffer Constructors
ensureCapacity( )
setLength( )
getChars( )
append( )
insert( )
reverse( )
replace( )
substring( )
StringBuilder
Number
Character
Boolean
Void
Process
Runtime
Memory Management
Runtime.Version
ProcessBuilder
System
Using arraycopy( )
Environment Properties
Object
Class
ClassLoader
Math
Trigonometric Functions
Exponential Functions
Rounding Functions
StrictMath
Compiler
Thread
ThreadGroup
Package
Module
ModuleLayer
RuntimePermission
Throwable
SecurityManager
StackTraceElement
Enum
ClassValue
java.lang.annotation
java.lang.instrument
java.lang.invoke
java.lang.management
java.lang.module
java.lang.ref
java.lang.reflect
Collections Overview
Using an Iterator
Spliterators
Comparators
Using a Comparator
Arrays
Vector
Stack
Dictionary
Hashtable
Properties
StringTokenizer
BitSet
Date
Calendar
GregorianCalendar
TimeZone
SimpleTimeZone
Locale
Random
Currency
Formatter
Formatting Basics
Formatting Numbers
Specifying Precision
Justifying Output
The # Flag
Closing a Formatter
Scanner
Scanning Basics
Setting Delimiters
java.util.function
java.util.jar
java.util.logging
java.util.prefs
java.util.regex
java.util.spi
java.util.stream
java.util.zip
File
Directories
Using FilenameFilter
Creating Directories
I/O Exceptions
InputStream
OutputStream
FileInputStream
FileOutputStream
ByteArrayInputStream
ByteArrayOutputStream
SequenceInputStream
PrintStream
Reader
Writer
FileReader
FileWriter
CharArrayReader
CharArrayWriter
BufferedReader
BufferedWriter
PushbackReader
PrintWriter
Serialization
Serializable
Externalizable
ObjectOutput
ObjectInput
ObjectInputStream
A Serialization Example
Stream Benefits
NIO Fundamentals
Buffers
Channels
Chapter # 23 Networking
Java has been associated with Internet programming. There are a number of
reasons for this, not the least of which is its ability to generate secure, cross-
platform, portable code. Java provide a convenient means by which programmers
of all skill levels can access network resources.
Beginning with JDK 11, Java has also provided enhanced networking support for
HTTP clients in the java.net.http package in a module by the same name Called the
HTTP Client API, it further solidifies Java’s networking capabilities.
Networking Basics
It will be useful to review some key networking concepts and terms.
Socket: A socket identifies an endpoint in a network, Sockets are at the
foundation of modern networking because a socket allows a single computer to
serve many different clients at once, as well as to serve many different types
of information. This is accomplished through the use of a port, which is a
numbered socket on a particular machine.
A server process is said to "listen" to a port until a client connects to it. A
server is allowed to accept multiple clients connected to the same port
number, although each session is unique. To manage multiple client
connections, a server process must be multithreaded or have some other means
of multiplexing the simultaneous I/O.
Socket communication takes place via a protocol. Internet Protocol (IP) is a
low-level routing protocol that breaks data into small packets and sends them to
an address across a network.
Transmission Control Protocol (TCP) is a higher-level protocol that manages
to robustly string together these packets, sorting and retransmitting them as
necessary to reliably transmit data.
A third protocol, User Datagram Protocol (UDP), sits next to TCP and can be
used directly to support fast, connectionless, unreliable transport of packets.
URLDecoder
URLEncoder
URLPermission
URLStreamHandler
InetAddress
The InetAddress class is used to encapsulate both the numerical IP address and
the domain name for that address.
You interact with this class by using the name of an IP host, which is more
convenient and understandable than its IP address.
The InetAddress class hides the number inside.
InetAddress can handle both IPv4 and IPv6 addresses.
Factory Methods
factory methods are merely a convention whereby static methods in a
class return an instance of that class. This is done in lieu of overloading a
constructor with various parameter lists when having unique method
names makes the results much clearer.
The InetAddress class has no visible constructors. To create an
InetAddress object, you have to use one of the available factory methods.
Three commonly used InetAddress factory methods are shown here:
Factory Methods Description
Static InetAddress getLocalHost( ) The getLocalHost( ) method
throws UnknownHostException simply returns the InetAddress
object that represents the local
host(System).
static InetAddress getByName(String hostName) The getByName( ) method
throws UnknownHostException returns an InetAddress for a
host name passed to it.
static InetAddress[ ] getAllByName(String The getAllByName( ) factory
hostName) method returns an array of
throws UnknownHostException InetAddresses that represent
all of the addresses that a
particular name resolves to.
getByAddress( ) Takes an IP address and returns
an InetAddress object. Either
inetAddress.isReachable(100);
InetAddress ip=InetAddress.getByName("www.google.com");
address = InetAddress.getByName("www.google.com");
System.out.println(address);
Instance Methods
The InetAddress class has several other methods, which can be used on
the objects returned by the methods.
// send Request
os.write(buf);
URL
The URL provides a reasonably intelligible form to uniquely
identify or address information on the Internet.
URLs are ubiquitous; every browser uses them to identify
information on the Web.
HttpURLConnection
Cookies
Datagrams
DatagramSocket
DatagramPacket
A Datagram Example
Introducing java.net.http
Events
Event Sources
Event Listeners
Event Classes
Sources of Events
Adapter Classes
Inner Classes
AWT Classes
Window Fundamentals
Component
Container
Panel
Window
Frame
Canvas
Displaying a String
Requesting Repainting
Introducing Graphics
Drawing Lines
Drawing Rectangles
Drawing Arcs
Drawing Polygons
Sizing Graphics
Color Methods
Responding to Controls
The HeadlessException
Labels
Using Buttons
Handling Buttons
CheckboxGroup
Choice Controls
Using Lists
Handling Lists
Using a TextField
Handling a TextField
Using a TextArea
FlowLayout
BorderLayout
Using Insets
GridLayout
CardLayout
GridBagLayout
Dialog Boxes
Chapter # 27 Images
File Formats
Loading an Image
Displaying an Image
Double Buffering
ImageProducer
MemoryImageSource
ImageConsumer
PixelGrabber
ImageFilter
CropImageFilter
RGBImageFilter
java.util.concurrent
java.util.concurrent.atomic
java.util.concurrent.locks
Semaphore
CountDownLatch
CyclicBarrier
Exchanger
Phaser
Using an Executor
Locks
Atomic Operations
Cancelling a Task
Restarting a Task
Things to Explore
Stream Basics
Stream Interfaces
Reduction Operations
Mapping
Collecting
Use Spliterator
Matcher
Reflection
DateFormat Class
SimpleDateFormat Class
Components
Containers
Event Handling
Painting in Swing
Painting Fundamentals
A Paint Example
JTextField
JButton
JToggleButton
Check Boxes
Radio Buttons
JTabbedPane
JScrollPane
Jlist
JComboBox
Trees
Jtable
Menu Basics
JMenuBar
JMenu
JMenuItem
Create a Toolbar
Use Actions
Advantages of Beans
Introspection
Persistence
Customizers
Introspector
PropertyDescriptor
EventSetDescriptor
MethodDescriptor
A Bean Example
Background
Using Tomcat
A Simple Servlet
Start Tomcat
Using Cookies
Session Tracking
@author
{@code}
@deprecated
{@docRoot}
@exception
@hidden
{@index}
{@inheritDoc}
{@link}
{@linkplain}
{@literal}
@param
@provides
@return
@see
@serialData
@serialField
@since
{@summary}
@throws
@uses
{@value}
@version
Add a Method
Create a Class
Use an Interface
Importing Packages
Exceptions