https://www.cnblogs.com/huachuantingyumian/p/16207004.html
public final class A{ }
public final void a()
final int a = 10;//不允许修改值 final String s = "string";//不允许指向其他对象
public abstract class A { public abstract void a(); }
public abstract class A { public abstract void a(); public void a1() { System.out.println("a1"); } }
public class A1 extends A{ @Override public void a() { } } public abstract class A1 extends A{ }
A a = new A() { @Override public void a() { } };
public abstract class A { public abstract void a(); } public class A1 extends A{ @Override public void a() { System.out.println("a"); } } public static void main(String[] args) { A a = new A1(); a.a(); A1 a1 = (A1) a; a1.a(); }
public interface A{ int a = 10; void A(); }
public interface A{ default void A(){ }; }
public interface Eat { void eat(); } public interface Drink { void drink(); } public class InterfaceTest implements Eat, Drink { @Override public void eat() { System.out.println("eat"); } @Override public void drink() { System.out.println("drink"); } }
public static void main(String[] args) { Eat eat = new InterfaceTest(); eat.eat(); Drink drink = new InterfaceTest(); drink.drink(); } //eat //drink
public static void main(String[] args) { Eat eat = new InterfaceTest(); eat.eat(); InterfaceTest interfaceTest = (InterfaceTest) eat; interfaceTest.eat(); } //eat //eat