Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Variables and Assignments

Posted By: Abree Rossi     Category: Java     Views: 1824

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.

 Type

 Description

 Keyword

 Character

 16 bit unicode character data

 char

 boolean

 true or false value

 boolean

 byte

 8 bit signed integer numbers

 byte

 short

16 bit signed integer numbers 

short 

integer 

32 bit signed integer numbers 

int 

long 

64 bit signed integer numbers 

long 

float  

32 bit signed floating point numbers 

float 

double 

64 bit signed floating point numbers 

double 




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.
  
Share: 

 
 

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!