Data types in Java


Data types in Java

Data types represent the different values to be stored in the variable.There are two forms of Data types in Java

  • Primitive data type
  • Non-primitive data type
Data Type Size (in bytes) Range
byte 1 -128 to 127
short 2 -32,768 to 32,767
int 4 -2,147,483,648 to 2,147,483,647
long 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float 4 Approximately ±3.40282347E+38F
double 8 Approximately ±1.7976931348623157E+308
char 2 0 to 65,535 (unsigned)
boolean 1 true or false


  • bool:Boolean data type consists of true and false values.
  • char:char data type is used to store the characters.
  • byte:The main purpose of byte is use to save memory and consists values in the range -128 to 127.
  • short: short consists value in the range -32768 to 32767
  • int: int consists value in the range -2,147,483,648 to 2,147,483,647.
  • long:consists values in the range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • float:float can be used to deal with decimal numbers. Always recommended to use float rather than double because float saves memory.
  • double:
  • double can be used to deal with decimal numbers.

Features of JAVA

There is given many features of java.They are also known as java buzzwords. The Java Features given below are simple and easy to understand.

Syntax of Java

Simple program in Java | Hello world Example We will create a file called Main.java and we use the following code to print "Hello learnwithvaigandla" to the screen.




Comments

Popular posts from this blog

Simple program in Java | Hello world Example

What is Object Oriented Programming in Java?

A Comprehensive Guide to Java and Its Applications: Exploring the Versatility of Java Programming