InterestingProblem - System.out.println"c2"...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
An interesting class Wednesday, October 26, 2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
public class C { /* basic reference operations */ static int j = 0; int i; // private Feld C(int j) { i = j;} void iCopy(C argObj) { this.i = argObj.i; } int iGet( ) {return i;} public static void main(String[] args) throws MyException1 { C c1 = new C(1); C c2 = new C(2); c1.iCopy(c2); System.out.println("c1: "+c1.iGet( ));
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println("c2: "+c2.iGet( )); } } • The i feld is private • in iCopy , the this reFerence can access a private feld oF another object. • is this legal? • is it good programming practice? • what are the costs? • what are the benefts? • How about with packages, package private, etc? Wednesday, October 26, 2011...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

InterestingProblem - System.out.println"c2"...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online