Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Member Access Java

Reply
Thread Tools

Member Access Java

 
 
aleksandr.fisher@gmail.com
Guest
Posts: n/a
 
      09-02-2007
Java has getter and setter methods that gives you access to the class
members. They are also called accessors and mutators.

Let say you have the private member declared:

private int x;

The accessor method would be:

public getX
{
return x;
}

The mutator method would be:

public setX(int var)
{
x=var;
}

Using this methods you can apply validity checks to your variables.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can derived member function not access protected member of a baseclass object? blangela C++ 8 09-26-2008 03:24 PM
Can a static member function access non-static member? dolphin C++ 3 12-05-2007 12:39 PM
Can Derived class static member access protected member from base class? Siemel Naran C++ 4 01-12-2005 06:46 PM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM
how do I access a member of vector when this vector is a member of a class ding feng C++ 8 07-02-2003 08:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57