Primitive type literals

A literal is the fourth of the Java tokens listed in the Input types section. It is the representation of a value. We will discuss literals of reference types in the Reference types and String section. And now we will talk about primitive type literals, only.

To demonstrate literals of primitive types, we will use a LiteralsDemo program in the  com.packt.javapath.ch05demo package. You can create it by right-clicking on the com.packt.javapath.ch05demo package, then selecting New | Class, and typing the LiteralsDemo class name, as we have described in Chapter 4, Your First Java Project.

Among primitive types, literals of the boolean type are the simplest. They are just two: true and false. We can demonstrate it by running ...

Get Introduction to Programming 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.