Data Types
Java have some predefined data types to store different type of data.
Below is the example of some data types:
Datatype mainly divide into two categories:
Primitive data type:
Primitive data type contains boolean, char, byte, short, int, long, float and double.
Non-Primitive or derived data type:
Non-primitive data type contains String, array and classes. Non-primitive data type create using primitive data type.
Data Type List:
Limit for all the data types to assign values, it will throw error if program try to assign big number to small variable.
Example:
As mentioned above the limit of byte to store value is from -128 to 127 and if we try to assign any value lesser than -128 and greater than 127 will lead us to below inline error:
Default value:
Below are the default values for all the data types:
Example:
Below is the example to print default values of some of the variables:
Example:
Below is the simple example to declare different data type and print there value.
Find ASCII value of character:
We can find out ASCII value of any character after type case it to int data type. ascii is the link to check all ascii keys and their values in detail. ASCII value from 97 to 122 represents small letter alphabets from a to z.
Get character from ASCII value:
We can type cast ASCII values from int to char for finding out the characters.
Capital case example:
ASCII value from 65 to 90 represents capital letter alphabets from A to Z.
Small case example:
ASCII value from 97 to 122 represents small letter alphabets from a to z.
Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.