Java interfaces are different from classes, and it’s important to know how to use their special properties in your Java programs. This tutorial introduces the difference between classes and interfaces, then guides you through examples demonstrating …
Classes and objects in Java must be initialized before they are used. You’ve previously learned that class fields are initialized to default values when classes are loaded and that objects are initialized via constructors, but there is more to initi…
Polymorphism refers to the ability of some entities to occur in different forms. It is popularly represented by the butterfly, which morphs from larva to pupa to imago. Polymorphism also exists in programming languages, as a modeling technique that …
Java provides a standard class library consisting of thousands of classes and other reference types. Despite the disparity in their capabilities, these types form one massive inheritance hierarchy by directly or indirectly extending the Object class…
Java supports class reuse through inheritance and composition. This two-part tutorial teaches you how to use inheritance in your Java programs. In Part 1 you’ll learn how to use the extends keyword to derive a child class from a parent class, invoke…
Classes, fields, methods, constructors, and objects are the building blocks of object-based Java applications. This tutorial teaches you how to declare classes, describe attributes via fields, describe behaviors via methods, initialize objects via c…
Java applications evaluate expressions in the context of statements, which are used for tasks such as declaring a variable, making a decision, or iterating over statements. A statement can be expressed as a simple or a compound statement:
A simple …
Java applications process data by evaluating expressions, which are combinations of literals, method calls, variable names, and operators. Evaluating an expression typically produces a new value, which can be stored in a variable, used to make a dec…
Java is an object-oriented programming language, but there’s more to Java than programming with objects. This tutorial is the first of several introducing non-object-oriented features and syntax that are fundamental to the Java language. You’ll lea…
So, you want to program in Java? That’s great, and you’ve come to the right place. The Java 101 series provides a self-guided introduction to Java programming, starting with the basics and covering all the core concepts you need to know to become a …