13.07.2015 Views

4. Object Structures, Aliasing, and Encapsulation

4. Object Structures, Aliasing, and Encapsulation

4. Object Structures, Aliasing, and Encapsulation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. Immutable objects must not depend on globalvariables:class Global {public static int a = 5;public static int getA(){return a;}}class Immutable2 {public int alwaysTheSame() {return Global.getA();}}Immutable2-objects are not immutable!The example demonstrates that mutability can depend on global state.13.05.13© A. Poetzsch-Heffter, TU Kaiserslautern16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!