Java Data Types

Java data type contains boolean, char, byte, short, int, long, float and double. 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

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan