1. abstract class
abstract class can have anything a normal class can have plus abstract method
public abstract class Test11 { public int a; private int b; public abstract void f1(); public void f2() { } }
2.interface
only final variable and abstract method,
can extends another interface, can extends more than 1 interface
cannot extends class or implement interface
public interface Inter2 extends Inter1, Inter2 { public int a = 1; public abstract void f1(); public void f2(); }
3. static nested class & inner class
http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class
Static nested class:
a static nested class is behaviorly a top level class
https://www.codeofaninja.com/2013/09/android-viewholder-pattern-example.html
public class StaticNestedOuter { public static void main(String[] args) { StaticNestedOuter.StaticNestedClass sn = new StaticNestedClass(); } static class StaticNestedClass { } }
Inner class:
public class OuterClass { private String baz; public static void main(String[] args) { OuterClass oc = new OuterClass(); InnerClass ic = oc.new InnerClass(); } public void foo() { InnerClass ic2 = new InnerClass(); } class InnerClass { public void print() { // access outer member in 2 ways System.out.print(OuterClass.this.baz); System.out.print(baz); } } }