Results 1 to 2 of 2
  1. #1
    tariqatherah is offline Member
    Join Date
    Nov 2011
    Rep Power

    Question instance private members accessed from other instances of the same type

    public class Test {

    private int someInt;

    public void testMethod(EtQEncryptionUtils testInstance){

    how could this class compile, while the testMethod is trying to use testInstance.someInt which is private in testInstance?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default 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,

    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. What is the use of marking Instance variable to private
    By rmurali.mcp in forum New To Java
    Replies: 2
    Last Post: 05-31-2011, 10:49 AM
  2. package-private members
    By ilya in forum Advanced Java
    Replies: 6
    Last Post: 05-03-2011, 09:59 AM
  3. private data members?
    By blueduiker in forum New To Java
    Replies: 10
    Last Post: 01-19-2010, 12:13 PM
  4. Replies: 1
    Last Post: 12-09-2009, 01:57 AM
  5. Replies: 1
    Last Post: 06-08-2009, 07:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts