View RSS Feed

Java Object

Initializing an Object

Rate this Entry
by , 04-26-2012 at 06:06 PM (498 Views)
Point class code is as following:
Java Code:
public class Point {
    public int x = 0;
    public int y = 0;
    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: 49
Size:  4.7 KB
Initializing an Object

Submit "Initializing an Object" to Facebook Submit "Initializing an Object" to Digg Submit "Initializing an Object" to Submit "Initializing an Object" to StumbleUpon Submit "Initializing an Object" to Google