View RSS Feed

Java Object

Declaring a Variable to Refer to an Object

Rate this Entry
by , 04-26-2012 at 06:02 PM (772 Views)
Now declaration of variable has been learned. You write:

type name;

It shows that the compiler which will be used name to refer, to the data, whose type will be type. Proper memory amount is also reserved by the declaration, for the variable.

Reference variable could also be declared at its own lines. Like, for example:

Point originOne;

When originOne is declared like this, value will stay un-determined till the actual creation of the object. Simple declaration of the reference variable will not be creating the object. For this purpose, new operator shall be used as it hs been prescribed in the coming section. An object shall be assigned to the originOne before using it in codes. Other way round compiler error will come.

Variable that doesn’t references the object can be illustrated as a variable name(originOne) + reference which points to nothing.

Submit "Declaring a Variable to Refer to an Object" to Facebook Submit "Declaring a Variable to Refer to an Object" to Digg Submit "Declaring a Variable to Refer to an Object" to del.icio.us Submit "Declaring a Variable to Refer to an Object" to StumbleUpon Submit "Declaring a Variable to Refer to an Object" to Google

Categories
Tutorial

Comments