12/3/2023 0 Comments Java four basic data types![]() ("Value Declared using Byte Data Type is " + byteData) Long longData = 20000000000000L // declaring long data typeįloat floatdata= 1.1f // declaring float data typeĭouble doubleData = 29.94d // declaring double data typeīoolean booleanData= true //declaring boolean data typeĬhar charData = 'A' // declaring character data type Short shortData= 6000 //declaring short data type Int intData= 20 // declaring integer data type In this example, we will show how to use different primitive types available in java programming:īyte byteData= 88 //declaring byte data type It can be used for storing only a single character, letter or ASCII values. It can be used for storing numbers having 15 decimal digits. It can be used for storing numbers having 6 to 7 decimal digits Stores positive and negative numbers ranging from -32,768 to 32,767. Stores positive and negative numbers ranging from -128 to 127. Here is a table showing different data types along with size: Primitive Data Type ![]() It can be used to store only a single character. Character: Character data type in java is declared using char keyword and consumes a space of 2 bytes.Boolean: Boolean data type is declared using boolean as a keyword, and it only allows two true or false values.While using double data type actual value should be followed with “d”. Double: Double data type is designed to store numbers having 14 to 15 decimal places.While using a float data type, actual data should be followed by “f”. Float: Float data type can store decimal values having 6 to 7 places of decimal.Float and double fall in this category of data types. This type of data type is designed in order to store decimal numbers. ![]() In the case of long data type, actual data should be necessarily followed by “L”. The long data type is usually preferred when data to be stored is out of range for an integer data type.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |