Data Type:
Data type is used to store the value in different formats like whole number, decimal numbers, characters, strings, and the Boolean values.
java contain he eight type of datatype they are BYTE,INT,SHORT,LONG,FLOAT,DOUBLE,CHAR,STRING,and BOOLEAN. But character does not taken as datatype because it is Unicode in java which is used to perform the compatibility for all the JVM (Java Virtual Machine).
Byte is the whole number in java and it contain the 8 bits as memory. To declare the byte datatype you need to enter like this --> byte b=10;
Int is the integer and it also contain the whole number .it contain the 32 bits or 4 bytes of memory. To declare the Int datatype type the following --> int b =10;
Short is also the whole number it contain the 16 bits and 2 bytes of memory in java. To declare this datatype type the following --> short b=10;
Long is also the whole number it contain the 64 bits and 8 bytes of memory. To declare the long datatype type the following --> long b=10;
These four datatype are whole numbers and they are called as INTEGER LITERALS. These are two type of the decimal point literals in java they are float and double. Whereas float is the 32 bit datatype and to declare the float datatype type the following code.---> float b=10.0;
Then double is the 64 bit datatype to declare the double datatype use --> double b=10.00;
String is the object in java and it is used to get the string objects in java. To declare this datatype use --> string s = tony;
Char is the unicode in java and it contain the ASCII code for the respective values.It is 16 bit and it contain the java Unicode in java. To declare this datatype --> char c=h;
Boolean is the datatype that contains TRUE or FALSE option . TO declare the datatype use --> boolean b = true;
boolean b= false;
IDENTIFIERS AND LITERALS:
Identifiers is used to identify the properties of the method and the object in java. For example to identify the person we use the name of the person. Now here , to identify the value we are using the variable name. It is used for the method , object and the variable name . For example, Now the variable is initialized like
int a=25;
In the above example the variable ( a ) contain the value 25 . Even though the variable is named as ( a ) while calling in technical it is named as Identifier.
class A{
int a=50;
public static void main (String args[])
{
A obj = new A();
System.out.println(obj);
}
}
When literals is the permanent value for the variable , ti contain the value according to the data type . For example the integer contain the value
int a=25;
In the above example the value 25 is called the literals.
And this is the end of this session , today we have learned DATA TYPES and IDENTIFIERS AND LITERALS.
No comments:
Post a Comment