From the course: Java 8+ Essential Training: Syntax and Structure

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Work with primitive variables

Work with primitive variables - Java Tutorial

From the course: Java 8+ Essential Training: Syntax and Structure

Start my 1-month free trial

Work with primitive variables

- [Instructor] Java has two broad categories of data types. Primitive data types are used to represent simple values such as numbers, characters, and booleans or true/false values. A variable that uses a primitive data type represents a single value. It's not a complex object. When you declare a variable that uses one of these types, you'll start with the type declaration. And you'll know that it's a primitive type because all of the primitive type names are in all lowercase, whereas complex object types are classes, and their initial character is uppercase. So for example, the int, which is an integer, a char, which is a single character, short, long, boolean, and so on, all of these names are all lowercase. On the other hand, the data type String is an object-based type, and so it has an uppercase S to indicate that it represents a class named String. When you declare a variable, you must declare its type. Java is a statically typed language, and on its own, it doesn't have any…

Contents