Java Basics:Data Types
Data Types in Java Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java: Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. Non-primitive data types: The non-primitive data types include Classes,Interfaces,Arrays. 1) Primitive data types In Java, we have eight primitive data types: boolean, char, byte, short, int, long, float and double. Java developers included these data types to maintain the portability of java as the size of these primitive data types do not change from one operating system to another. byte , short , int and long data types are used for storing whole numbers. float and double are used for fractional numbers. char is used for storing characters(letters). boolean data type is used for variables that holds either true or false. byte: This can hold whole number between -128 and 127. Mostly used to save memory and when you