Accesing the private members between the instance of same class
From: Vijay (vij_singh_at_hotmail.com)
Date: 12/13/04
- Next message: Phlip: "Re: Accesing the private members between the instance of same class"
- Previous message: Michael Rauscher: "Re: OOA and OOD"
- Next in thread: Phlip: "Re: Accesing the private members between the instance of same class"
- Reply: Phlip: "Re: Accesing the private members between the instance of same class"
- Reply: H. S. Lahman: "Re: Accesing the private members between the instance of same class"
- Reply: James J. Gavan: "Re: Accesing the private members between the instance of same class"
- Reply: Robert C. Martin: "Re: Accesing the private members between the instance of same class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 Dec 2004 04:48:03 -0800
Hi
I don't know if this is language specific, but in java a object can
access the private members of another object which belongs to same
class. Is this the OOP specific, or is this OOD principle.
Following is the example :
public class TestInstance
{
private int v_test1;
private int v_test2;
public static void main(String[] args)
{
TestInstance ts1 = new TestInstance(1, 2);
TestInstance ts2 = new TestInstance(3, 4);
System.out.println("Value of the 1st instance is: "+ ts1.v_test1 +
ts1.v_test2);
System.out.println("Value of the 1st instance is: "+ ts2.v_test1 +
ts2.v_test2);
}
public TestInstance(int x, int y)
{
v_test1 = x;
v_test2 = y;
}
}
Regards
Vijay
- Next message: Phlip: "Re: Accesing the private members between the instance of same class"
- Previous message: Michael Rauscher: "Re: OOA and OOD"
- Next in thread: Phlip: "Re: Accesing the private members between the instance of same class"
- Reply: Phlip: "Re: Accesing the private members between the instance of same class"
- Reply: H. S. Lahman: "Re: Accesing the private members between the instance of same class"
- Reply: James J. Gavan: "Re: Accesing the private members between the instance of same class"
- Reply: Robert C. Martin: "Re: Accesing the private members between the instance of same class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|