Declaring a Variable to Refer to an Object
by, 04-26-2012 at 05:02 PM (708 Views)
Now declaration of variable has been learned. You write:
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:
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.