/**
* 父类A
* @author Rick
*
*/
public class A {
public void say() {
System.out.println("哈哈A!");
}
* 父类A
* @author Rick
*
*/
public class A {
public void say() {
System.out.println("哈哈A!");
}
}
/**
* 子类B
* @author Rick
*
*/
public class B extends A {
@Override
public void say() {
System.out.println("哈哈B!");
}
}
/**
* 测试匿名类和匿名内部类
* @author Rick
*
*/
public class Test {
private void doSth(A a) {
a.say();
}
public static void main(String[] args) {
Test t = new Test();
t.doSth(new B()); //匿名类
t.doSth(new A() { //匿名内部类
@Override
public void say() {
System.out.println("22222");
}
});
}
}