PRODUCT SUPPORT ANNOUNCEMENT
Some videos and Web Editions may be returning errors on launch. Learn more.
Detailed yet accessible, Java Rules is a comprehensive reference for the application programmer who needs to master the intricacies of the Java programming language. Thoroughly describing the core of the Java programming language and the Java virtual machine (JVM), Java Rules makes it possible for programmers to efficiently master the Java platform.
Based on the second editions of The Java Language Specification and The Java Virtual Machine Specification, Java Rules presents a subset of those specifications in a gentle tutorial style. From platform basics to APIs, this encyclopedic guidebook reveals every facet of the language--including previously undocumented features. Throughout the book, practical tutorials are supported with official language documentation or with insights shared by respected leaders. The book's unique format and conversational style are ideally suited for experienced programmers seeking a short path to language proficiency.
As both a tutorial and detailed reference, this volume of Java Rules covers:
With Java Rules in hand, both novices and experienced programmers can quickly master the language.
Click below for Sample Chapter related to this title:
About This Book.
A Java Tradition.
1. Lexical Structure.
Commenting Out Large Blocks of Code.
Java Naming Conventions.
The Terminology of Class Body Declarations.
The Definition of Fields in Java.
Recognizing Constructors in Source Code.
Anatomy of a Compilation Unit.
Special Initialization Methods.
The Significance of Textual Order.
Limit of One “public” Package Member.
The Members of a Package.
Using the SDK to Develop Packages.
Importing Nested Classes of All Sorts (Top-Level or Inner).
How Import Declarations are Used by a Compiler.
The Efficiency of Type-Import-on-Demand Declarations.
Class Type Declarations.
Interface Type Declarations.
The Definition of Top-Level Classes.
Helper Classes are Not Fundamentally Different.
Technical Arguments Against the Use of Helper Classes.
The Five Kinds of Classes and Interfaces.
“Public” Top-Level Classes.
Non-“public” Member Classes.
Local and Anonymous Classes.
Choosing Which Kind of Class to Use.
From “VectorEnumerator” to an Anonymous Class.
The Rationale for Containment and Inner Class Hierarchies.
Containment and Inner Class Hierarchies.
Inner Class Hierarchies.
The “static” Modifier.
The Definition of “static” Context.
The “static” Context in an Inner Class Hierarchy.
The “this” and “super” Keywords.
The Current Object (“this”).
The Direct Superclass (“super”).
Practical Uses of the “this” and “super” Keywords.
Using “super” to Reference Members in Different Packages.
Multiple Current Instances (a.k.a. Levels).
A Note About Deeply Nested Types.
Qualifying the “this” Keyword.
Qualifying the “new” Keyword.
Qualifying the “super” Keyword.
The Definition of Data Types.
Data Type as a Set of Values.
The Object-Oriented Definition of Type.
Numeric Data Types.
Understanding the Floating-Point Types.
The “char” Data Type.
The “boolean” Data Type.
The “null” Type.
The “Number” Class.
The “java.math” Package.
The “BigInteger” Class.
The “BigDecimal” Class.
Inexact Results and Comparison Operators.
Rounding the Result of a Floating-Point Operation.
Using Integral Types to Store Monetary Values.
Primitive Type Wrapper Classes.
Parsing Strings for Primitive Type Values.
Converting Primitive Numeric Types to Strings.
Bit Pattern Manipulation.
Accessing Primitive Type System Properties.
Unicode Utility Methods.
The “Object” Class.
Reference Equality Versus the Equivalence Relationship.
Understanding Hash Tables.
The Five Housekeeping Methods.
The Comparison Methods.
What is Default Ordering?
What is Natural Ordering?
Reverse Order (or Descending) Sorts.
Sorting By More Than One Field.
The “Comparable” Interface.
The “Comparator” Interface.
Would-Be Mutator Methods.
The Length of a “String” or “StringBuffer”.
The Capacity of a “StringBuffer”.
Ensuring the Capacity of a “StringBuffer”.
Right-Open Intervals in “String” and “StringBuffer”.
Checked Exceptions in String and “StringBuffer”.
The “String” Class.
Accessing Individual Characters or Substrings.
“char” to “String” Conversions and Vice Versa.
Translating Locally Encoded Strings.
Miscellaneous Methods in the “String” Class.
Unusual Constructors in the “String” Class.
The “StringBuffer” Class.
The Overloaded insert and append Methods.
Other Methods in the “StringBuffer” Class.
Other String-Related Classes.
The “StringCharacterIterator” Class.
The “StringReader” and “StringWriter” Classes.
The “BreakIterator” Class.
The “StringTokenizer” Class.
The “StreamTokenizer” Class.
String Concatenation Operations.
A Note about the Overloaded Binary + Operator.
Implicit String Conversions.
The Intern Mechanism.
Shared Character Buffers.
Displaying Diagnostic Messages on the Console.
The “print” and “println” Methods.
The Locale” Class.
The Default Locale.
The “Date” Class.
The “GregorianCalendar” Class.
Instantiating the “GregorianCalendar” Class.
The Inconsistent Field Rule.
The Maximum DAY_OF_MONTH Rule.
Date and Time Fields in the Calendar Class.
Standard Default Values for Date and Time Fields.
Normalizing Date and Time Fields.
Date and Time Field Manipulation Methods.
The “TimeZone” Class.
Understanding the Difference between i18n and l10n.
The Localization of Common Data Types.
Formatting Dates and Times.
Array, Component, and Element Types.
The Canonical Form of the “for” Loop.
Array Classes Are Dynamically Created.
The Members of an Array Type.
Array Type Variable Declarations.
Initializing Array Type Variables.
Array Access Expressions.
A Bridge over Troubled Waters (the “toArray” Methods).
Untyped References versus Parameterized Types.
What Is Run-Time Type?
Time Complexities (or Big-O Notation).
Constant Time Operations.
Amortized Constant Time.
The Equivalence Relationship and Elements.
Using Mutable Objects as Elements in a “Set” or Keys in a “Map”.
The Collections Framework.
The Principle of Maximum Generality.
The “Collection” Interface.
The Map Interface.
Housekeeping Methods for Containers.
Choosing a General-Purpose Implementation.
Performance Tuning the General-Purpose Implementations.
Range Views (Sublists, Subsets, and Submaps).
Collection Views of a Map.
List View of an Array.
Using Collection Views to Iterate over a Map.
A Poor Man's Collection.
Iterating Backwards Through a “TreeSet” or “TreeMap”.
Al-Khwarizmi Concerning the Hindu Art of Reckoning.
Utility Methods for “Arrays” and Other “Collections”.
Cloning versus Copying a Container.
The Minimum and Maximum Elements.
An “equals” Method for Arrays.
Custom Implementations of the Core Collection Interfaces.
Multimaps and Multidimensional Arrays.
This book has been under continuous development for over five years, since shortly after the JDK 1.0 release in 1995.Married to the Java Specifications
This book is based on the Java Language Specification (JLS). In fact, I started out to write what I regarded as The Java Language Specification for Application Programmers. Shortly thereafter, however, I realized that material from The Java Virtual Machine Specification (JVMS) would have to be included as well. This work has grown to include everything of interest to mainstream business application programmers in a host of Java specifications, including the second editions of both the JLS and the JVMS.The Target Audience
The main difference between the specifications and this book is the target audience. The JVMS is, of course, written for someone who wants to implement a JVM. What is not as generally understood is that the JLS is a grammar primarily intended for someone who wants to write a Java compiler, such as the
jikes compiler team at IBM. Thus, it includes a lot of material that is of interest only to programmers who make a living in the arcane world of compilers. That is truly unfortunate because the JLS contains a wealth of information of interest to application programmers that rarely makes it into mainstream Java books. The same can be said of the JVMS. This book extracts all of that information, elaborates upon it where necessary, and presents it in a technical writing style appropriate for mainstream business application programmers.
Mainstream business application programmers are the target audience. By that I mean working programmers, most of whom will be found in corporations outside of Silicon Valley. They are experienced professionals who need to learn the language at a professional level in the first pass. This requires a serious and dedicated focus on the part of the reader. Mainstream business application programmers have that focus. They bring to the subject years of experience and a strong motivation to learn.
More generally, this book is for any programmer who wants to truly master the basics of the Java programming language. While formalism and stylistic norms forbid me from including students in the target audience, I firmly believe that these books can be profitably used to teach the Java programming language (if not as the primary text, then as an auxiliary reference work).