From the course: Java 11+ Essential Training

Unlock the full course today

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

Work with primitive variables

Work with primitive variables - Java Tutorial

From the course: Java 11+ Essential Training

Start my 1-month free trial

Work with primitive variables

- [Instructor] Java is a statically typed language. That means that all variables have types that are set when the variable is declared. And once set, a variable's type can't be changed. There are two major categories of data types in Java, primitives and objects. A primitive variable is stored in the fastest possible memory. These include numbers, single characters, but not full strings, and Boolean values. Primitive types can contain a single value. They're not complex objects, so they don't have members such as methods or fields. The types for primitives are all lowercase. That's how you can recognize them in your code. And they include these, int for interger, char for character, short and long for different kinds of integers, double and float for different sorts of floating values, and Boolean. A string is not a primitive in Java. It's a complex object, an instance of a class, and we'll get to strings later. You…

Contents