Results 1 to 2 of 2
- 11-17-2011, 11:35 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
instance private members accessed from other instances of the same type
public class Test {
private int someInt;
public void testMethod(EtQEncryptionUtils testInstance){
System.out.println(testInstance.someInt);
}
}
how could this class compile, while the testMethod is trying to use testInstance.someInt which is private in testInstance?
- 11-17-2011, 12:10 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: instance private members accessed from other instances of the same type
The access specifier 'private' works on the class level, i.e. two different objects of the same class can manipulate each others' private members.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
What is the use of marking Instance variable to private
By rmurali.mcp in forum New To JavaReplies: 2Last Post: 05-31-2011, 10:49 AM -
package-private members
By ilya in forum Advanced JavaReplies: 6Last Post: 05-03-2011, 09:59 AM -
private data members?
By blueduiker in forum New To JavaReplies: 10Last Post: 01-19-2010, 11:13 AM -
declare a private instance variable called ran of type random
By tinman in forum New To JavaReplies: 1Last Post: 12-09-2009, 12:57 AM -
[error] No enclosing instance of type RobotTest is accessible
By jon80 in forum New To JavaReplies: 1Last Post: 06-08-2009, 07:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks