Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Variables and Assignments

Posted By: Abree Rossi     Category: Java     Views: 2641

This article explains variables available in java with example.

What is Variable?

A variable is a named memory location that can hold a value. In java all variables must be declared before they can be used. A variable declaration tells the compiler what type of variable is being used.

Java supports eight different basic data types as shown below.





 16 bit unicode character data



 true or false value



 8 bit signed integer numbers



16 bit signed integer numbers 



32 bit signed integer numbers 



64 bit signed integer numbers 



32 bit signed floating point numbers 



64 bit signed floating point numbers 


To declare a variable use below form.

type variable_name;

char type is 16 bit long and is used to hold a single unicode character.
boolean type is used t store either true or false.
byte, short, int and long type variables holds signed whole numbers.
float and double type variables holds signed floating point values, which may have fractional components. The difference between float and double is that double provides about twice the precision as does float.


Didn't find what you were looking for? Find more on Variables and Assignments Or get search suggestion and latest updates.

Abree Rossi
Abree Rossi author of Variables and Assignments is from Rome, Italy.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!