|
Page 1 of 1
|
[ 1 post ] |
|
mkalaiyarasan
As a Family
Joined:
Tue Aug 25, 2009 5:25 pm
Beans: 35
In Bank: 0
College: studied
Degree: BE
Department: cse
State: Tamilnadu
Fav Quote: cse
Position: Employee
|
|
Thu Sep 03, 2009 7:09 am
|
Post subject: getter methods
Also known as accessor methods, getter methods just return the value of a field in a class. class TwoDPoint { double x; double y; String getAsString() { return "(" + this.x + "," + this.y + ")"; } void setX(double value) { this.x = value; } void setY(double value) { this.y = value; } double getX() { return this.x; } double getY() { return this.y; } } TwoDPoint origin = new TwoDPoint(); origin.setX(0.0); origin.setY(0.0); System.out.println("The x coordinate is " + origin.getX());
|
|
|
|
|
Page 1 of 1
|
[ 1 post ] |
|