Skip to main content

Data Types and Variables

Learn Data Types and Variables (Java Basics, Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

1. Introduction A data type tells Java what kind of value a variable can hold and how much memory it needs Java is statically typed, so the type is declared first and checked by the compiler. There are eight primitive types (byte, short, int, long, float, double, char, boolean) that hold the value directly, and reference types such as String, arrays, classes and enums that hold the address of an object . Var is only local type inference, the exact static type is still written into the class file.

More lessons in Java Basics