Java Reference
In-Depth Information
String goodBye = "Good Bye";
public void sayGoodBye(){
System.out.println(this.goodBye);
}
}
public static void main (String[] args){
StaticInnerExample.sayHello();
StaticInnerExample.InnerExample inner =
new StaticInnerExample.InnerExample();
inner.sayGoodBye();
}
}
Inner classes help to provide encapsulation of logic. Furthermore, they allow inher-
itance of private fields, which is not possible using a standard class.
Summary
Java is an object-oriented language. To harness the capabilities of the language, one
must learn how to become proficient with object-orientation. This chapter covered ba-
sics such as class creation and access modifiers. It also covered encapsulation, inter-
faces, and recipes to help developers take advantage of the power of object orientation.
Lastly, this chapter included information on a new feature of Java 8 known as default
methods.
Search WWH ::




Custom Search