class Outer {
String outer;
// Assign values using constructor
public Outer(String name) {
this.outer = name;
}
// private method
private String getName() {
return this.outer;
}
}
// Non-static nested class
class Inner {
String inner;
String outer;
public String getOuter() {
// Instantiate outer class to use its method
outer = Outer.this.getName();
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter