- 注册时间
- 2004-10-13
- 最后登录
- 2019-5-15
⑧专业
*永恒国度*
- 积分
- 14145

|
- class Test{
- public void hi(){
- System.out.println("hi!");
- }
- public void hello(){
- System.out.println("hello");
- }
- }
- public class HelloWorld{
- public static void main(String[] args){
- Test ob=new Test(){
- public void hi(){
- System.out.println("fuck you");
- }
- };
- ob.hi();
- ob.hello();
- }
- }
复制代码 是这样的,书上给的一个例子,以我所知,匿名类就是为了不用创建对像,但它写成这样不就是创建了对像了吗? |
|