Java Reference types
Java Reference types
- To create new data types, complex data types, containing simple primitives or other complex data types you must create a class.
- Reference type can refer to a created object out of a such class or can refer to an array object containing many elements of the same type.
-
They are called reference types because they "refers to" data type that is often large.
Java Reference example:
... Foo myFoo = new Foo( ); // The new keyword creates a object of class type Foo // myFoo is a reference-type variable that holds a // reference to the newly constructed Foo object Foo anotherFoo = myFoo; // There are now two identical references: // "myFoo" and "anotherFoo" int i=20; // In this case method1 and method2 are defined // in the Foo class myFoo.method1( myFoo ); // Object (myFoo) are always passed to // methods by reference myFoo.method2( i ); // Primitive are passed to methods by values ...
© 2010 by Finnesand Data.
All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the
correctness in the pages or source codes.
The risk of using this web-site pages or any program
codes from this website is entirely at the individual user.