Friday, December 9, 2016

Inner class - Example1

class Outer {
static class Inner {
static void m1(){
System.out.println("Hi I am Inside m1() method");
}
public void m2(){
System.out.println("Will this static and non static work without main() method ?");
}
public static void main(String args[]) {
System.out.println("Hi Balaji how are you ?");
new Inner().m2();
Inner.m1();
}
}

public static void main(String args[]) {
Inner inner = new Inner();
}
}

//Execute this and see
Run using
javac Outer.java
java Outer$Inner

No comments:

Post a Comment