Solved

access private field

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example 17 59
how to install java on RHEL image on EC2 4 57
String array comparison 4 46
ejb entity bean example issue 2 26
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…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

749 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