In this example we will show how to access outer class from inner class in Java.
Source Code
package com.beginner.examples;
class Out {
String a = "test";
class In {
public String test() {
return a;
}
}
}
public class Main {
public static void main(String args[]) {
Out out = new Out();
Out.In in = out.new In();
System.out.println(in.test());// call inner class
}
}
Output:
test