?
Solved

access private field

Posted on 2002-03-13
2
Medium Priority
?
167 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 1200 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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