Java Primitive Data Types

As mentioned above, Java is a statically-typed language. This means that all variables must be declared before they can be used.


\begin{lstlisting}
int speed;
\end{lstlisting}

Here, $\lstinline{speed}$ is a variable, and the data type of the variable is $\lstinline{int}$. The $\lstinline{int}$ data type determines that the speed variable can only contain integers. In simple terms, a variable's data type determines the values a variable can store. There are 8 data types predefined in Java programming language, known as primitive data types. In addition to primitive data types, there are also referenced data types in Java (you will learn about it in later chapters).