Learning the Java Language Table of Contents Object-Oriented Programming Concepts What Is an Object? What Is a Class? What Is Inheritance? What Is an Interface? What Is a Package? Questions and Exercises: Object-Oriented Programming Concepts Language Basics Variables Primitive Data Types Arrays Summary of Variables Questions and Exercises: Variables Operators Assignment, Arithmetic, and Unary Operators Equality, Relational, and Conditional Operators Bitwise and Bit Shift Operators Summary of Operators Questions and Exercises: Operators Expressions, Statements, and Blocks Questions and Exercises: Expressions, Statements, and Blocks Control Flow Statements The if-then and if-then-else Statements The switch Statement The while and do-while Statements The for Statement Branching Statements Summary of Control Flow Statements Questions and Exercises: Control Flow Statements Classes and Objects Classes Declaring Classes Declaring Member Variables Defining Methods Providing Constructors for Your Classes Passing Information to a Method or a Constructor Objects Creating Objects Using Objects More on Classes Returning a Value from a Method Using the this Keyword Controlling Access to Members of a Class Understanding Class Members Initializing Fields Summary of Creating and Using Classes and Objects Questions and Exercises: Classes Questions and Exercises: Objects Nested Classes Inner Class Example Local Classes Anonymous Classes Lambda Expressions Method References When to Use Nested Classes, Local Classes, Anonymous Classes, and Lambda Expressions Questions and Exercises: Nested Classes Enum Types Questions and Exercises: Enum Types Annotations Annotations Basics Declaring an Annotation Type Predefined Annotation Types Type Annotations and Pluggable Type Systems Repeating Annotations Questions and Exercises: Annotations Interfaces and Inheritance Interfaces Defining an Interface Implementing an Interface Using an Interface as a Type Evolving Interfaces Default Methods Summary of Interfaces Questions and Exercises: Interfaces Inheritance Multiple Inheritance of State, Implementation, and Type Overriding and Hiding Methods Polymorphism Hiding Fields Using the Keyword super Object as a Superclass Writing Final Classes and Methods Abstract Methods and Classes Summary of Inheritance Questions and Exercises: Inheritance Numbers and Strings Numbers The Numbers Classes Formatting Numeric Print Output Beyond Basic Arithmetic Summary of Numbers Questions and Exercises: Numbers Characters Strings Converting Between Numbers and Strings Manipulating Characters in a String Comparing Strings and Portions of Strings The StringBuilder Class Summary of Characters and Strings Autoboxing and Unboxing Questions and Exercises: Characters and Strings Generics (Updated) Why Use Generics? Generic Types Raw Types Generic Methods Bounded Type Parameters Generic Methods and Bounded Type Parameters Generics, Inheritance, and Subtypes Type Inference Wildcards Upper Bounded Wildcards Unbounded Wildcards Lower Bounded Wildcards Wildcards and Subtyping Wildcard Capture and Helper Methods Guidelines for Wildcard Use Type Erasure Erasure of Generic Types Erasure of Generic Methods Effects of Type Erasure and Bridge Methods Non-Reifiable Types Restrictions on Generics Questions and Exercises: Generics Packages Creating and Using Packages Creating a Package Naming a Package Using Package Members Managing Source and Class Files Summary of Creating and Using Packages Questions and Exercises: Creating and Using Packages« Previous