Solved

access private field

Posted on 2002-03-13
2
166 Views
Last Modified: 2010-03-31
The private fields and methods of an object can only be accessed by the object itself and by other objects of the same class (siblings). An object may touch its

sibling's private parts. A sibling is an object in the same class but which is not the same object.

i read this from http://www.hig.no/at/data/progwww/Java/docs/3.doc

anyone had any example on how sibling can access a private field of another object?
0
Comment
Question by:malek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
saxaboo earned 300 total points
ID: 6860210
public class Test
{
   private int i = 1;

   public void displaySibling(Test b)
   {
       System.out.println(b.i);
   }
}



-S
0
 

Author Comment

by:malek
ID: 6860237
cool, thanks
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question