My Anna

Indias Biggest Engineering Education Community Enriching Students Minds with Latest Placement Papers, Study Materials, Fresher Jobs and Free E Books

A Unit of Aim Clear Technologies Ltd.
Search Study Materials, Jobs, Placement Papers, Interview Tips, Training Videos & More

Advertise with us

Who is online



Post new topic Reply to topic  [ 1 post ] 

mkalaiyarasan
As a Family
As a Family
User avatar

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
 
#2
Thu Sep 03, 2009 7:09 am
Post subject: getter methods Post
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());

Profile E-mail
Offline

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 
Bookmark & Share

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB Group.

phpBB SEO