Java Data Types

Every program you write deals with data in some form. Java has several types of data it can work with, and this chapter covers some of the most important.

Although Java is a language based on classes and all Java programs are built from classes, not all data types in Java are classes. In Java, there are two categories into which data types have been divided using this distinction:

  • Primitives

  • Reference types

Primitives

Primitives are data types whose state represents a number, a character, or a true/false indication.

Primitive types are not class types; they do not provide any behavior associated with the type-appropriate values they hold. Java has eight primitive types that should look familiar to you from other languages:

  • boolean ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.