Data types

In every programming language storing of the data is crucial and data types play a vital role in storing the data.Java is no exception for this.Generally data types are divided into two types. There are numeric and character data type. Each and every data type have sub division in this.Let us learn each and every type in detail.

Numeric:Numeric data types include integers and floating numbers.Among integer there are four types.They are byte,int,short,long.The ranges and size of these data types is:

  1. byte:-128 to 127 and size is 1 byte.
  2. short:-32768 to 32767 and size is 2 bytes.
  3. int:-2148483648 to 2148483647 and size is 4 bytes.
  4. long:-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and size is 16 bytes.

For real numbers there are two types of data types.They are float and double and size of these data types is 4 bytes and 8 bytes respectively.The main difference is the precision given by them.For floating point after decimal point we get 6 digits and for double we get 12 digits.
For characters there is only one datatype which is char.The main difference between char data type of c,c++ and java is the size of this datatype. In java the size is 2 bytes and in c,c++ it is 1 byte.The main advantage of the java char is when we assign any numeric value to this data type it is automatically converted into the corresponding character.
In addition to this datatypes java as one more datatype called as boolean.It takes only TRUE or FALSE as it’s input value.

Advertisements

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my Master's in Computer Science.
This entry was posted in Java and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s