Who Knows All.. ?

If the answer is No one. Then this blog is for U. I'm going to put all the things I know in Java

What is a Variable? What are the different types of variables in java?

   A variable is nothing but a cup.A container.It holds something.Variables must have a type and a name.
Variables come in two flavors in java.

  • Primitive Variables 
  • Reference Variables
                   Primitives Variables hold the fundamental values which includes booleans, integers, characters and floating point numbers. There are 8 types of primitive variables (data types) in java.
  1. boolean
  2. byte(8 bits)
  3. short(16 bits)
  4. int(32 bits)
  5. long(64 bits)
  6. char
  7. float
  8. double
                      Reference Variables are special type of data types in java which hold reference to the objects. As we all know Java is an object-oriented programming language, these reference variables play a vital role in  every application. Reference variable is just like a remote control pointing to a television. Likewise  a reference variable is pointed(referenced) to an object to invoke its methods and instance variables. The bits hold by reference variable are of JVM specific. Every reference variable of that particular JVM is of same size irrespective of the object size.
Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Information

This entry was posted on November 2, 2011 by in Data types, Variable.
%d bloggers like this: