Solved

access private field

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now