1public Class A{
2
3 private String myData;
4
5 public String getMyData(){
6 return myData;
7 }
8
9 public void setMyData(String data){
10 this.myData=data;
11 }
12}
1class Display {
2
3 //Private nested or inner class
4 private class InnerDisplay {
5 public void display() {
6 System.out.println("Private inner class method called");
7 }
8 }
9
10 void display() {
11 System.out.println("Outer class (Display) method called");
12 // Access the private inner class
13 InnerDisplay innerDisplay = new InnerDisplay();
14 innerDisplay.display();
15 }
16}
17
18public class Main {
19
20 public static void main(String args[]) {
21 // Create object of the outer class (Display)
22 Display object = new Display();
23
24 // method invocation
25 object.display();
26 }
27}