2

Variables and Primitive Data Types

In Chapter 1, we introduced the compiler and the JVM. We learned how to use both of them from the command line when we wrote our first Java program, HelloWorld. We also introduced IntelliJ, a powerful and friendly IDE, and we ran HelloWorld from there as well.

All programming languages require variables and provide in-built primitive data types. They are essential for the operation of even the simplest programs. By the end of this chapter, you will be able to declare variables using Java’s primitive types. In addition, you will understand the differences between the various primitive data types and which ones to use in a given situation.

In this chapter, we are going to cover the following main topics:

Get Learn Java with Projects 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.