Solved

access private field

Posted on 2002-03-13
2
164 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

809 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