© Mikael Olsson 2022
M. OlssonJava 17 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-7371-5_3

3. Variables

Mikael Olsson1  
(1)
Hammarland, Länsi-Suomi, Finland
 

Variables are used for storing data in memory during program execution.

Data Types

Depending on what data you need to store, there are several kinds of data types. Java has eight types built into the language, called primitives . The integer (whole number) types are byte, short, int, and long. The float and double types represent floating-point numbers (real numbers). The char type holds a Unicode character, and the boolean type contains either a true or false value. Except for these primitive types, every other type in Java is represented by a class, an interface, or an array.

Data ...

Get Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language, APIs, and Library 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.