|
-
Feb 27th, 2007, 09:52 PM
#1
Thread Starter
PowerPoster
[RESOLVED] access control "private"
Let say I have a private instance variable in a Java code.
Code:
class SetName
{
private String Name;
// rest of the code goes here
}
Is there any direct/indirect way to retrieve or set its value from other classes.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Feb 28th, 2007, 11:05 AM
#2
Re: access control "private"
Indirect, yes: define a setter. But the whole point of private variables is that they can't be accessed from other classes.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 28th, 2007, 09:12 PM
#3
Thread Starter
PowerPoster
Re: access control "private"
How about the methods such as void, no return value.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Mar 1st, 2007, 08:25 AM
#4
Re: access control "private"
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 4th, 2007, 10:12 PM
#5
Thread Starter
PowerPoster
Re: access control "private"
I mean how can work on such a variable on a method like void which has no return value.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Mar 4th, 2007, 11:26 PM
#6
Addicted Member
Re: access control "private"
the void methods are used to manipulate the private instance variables of the class
-
Mar 5th, 2007, 12:39 AM
#7
Thread Starter
PowerPoster
Re: access control "private"
How poor I'm to miss this point. Thanks
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|