Integer Literals

Integer literals are used to initialize variables of integer data types byte, short, int and long. If an integer literal ends with l or L, it's of type long.


\begin{lstlisting}
// Error! literal 42332200000 of type int is out of range
int...
...ong, and it's not out of range
long myVariable2 = 42332200000L;
\end{lstlisting}

Integer literals can be expressed in decimal, hexadecimal and binary number systems. The numbers starting with prefix $0x$ represents hexadecimal. Similarly, numbers starting with prefix $0b$ represents binary.


\begin{lstlisting}
// decimal
int decNumber = 34;
int hexNumber = 0x2F; // 0x re...
...ts hexadecimal
int binNumber = 0b10010; // 0b represents binary
\end{lstlisting}