View RSS Feed

Java Object

Initializing an Object

Rate this Entry
by , 04-26-2012 at 05:06 PM (461 Views)
Point class code is as following:
Java Code:
public class Point {
    public int x = 0;
    public int y = 0;
    //constructor
    public Point(int a, int b) {
        x = a;
        y = b;
    }
}
Single constructor is present in this class. One may do the recognition of the constructor as same name is used by the declaration as the class does & no return type is there. Constructor present will be taking 2 integer arguments which have been declared by code (int a, int b). Values 94 and 23 are provided by the following statement, for those arguments:
Java Code:
Point originOne = new Point(23, 94);
This statement execution’s result has been illustrated in the given figure:
Name:  1.jpg
Views: 48
Size:  4.7 KB
Initializing an Object

Submit "Initializing an Object" to Facebook Submit "Initializing an Object" to Digg Submit "Initializing an Object" to del.icio.us Submit "Initializing an Object" to StumbleUpon Submit "Initializing an Object" to Google

Categories
Tutorial

Comments