• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
wangchunmei
博客园 首页 新随笔 联系 订阅 订阅 管理

2013年4月21日

匿名类
摘要: abstract class Student{abstract void speak();}class Teacher{void look(Student stu){stu.speak();}}public class Example5_16{public static void main(String arg[]){Teacher zhang=new Teacher();zhang.look(new Student(){void speak(){System.out.println("这是匿名类中的方法");}});}}interface Show{public void 阅读全文
posted @ 2013-04-21 22:02 wangchunmei 阅读(178) 评论(0) 推荐(0)
 
接口回调(接口回调和接口作为参数)
摘要: interface ShowMessage{void showTradeMark();}class TV implements ShowMessage{public void showTradeMark(){System.out.println("我是电视机");}}class PC implements ShowMessage{public void showTradeMark(){System.out.println("我是电脑");}}public class Example5_12{public static void main(String a 阅读全文
posted @ 2013-04-21 21:36 wangchunmei 阅读(395) 评论(0) 推荐(0)
 
类实现接口(Example5_11)
摘要: interface Computable{final int MAX=100;int f(int x);public abstract int g(int x,int y);}class A implements Computable{public int f(int x){return x*x;}public int g(int x,int y){return x+y;}}class B implements Computable{public int f(int x){return x*x*x;}public int g(int x,int y){return x*y;}}public c 阅读全文
posted @ 2013-04-21 21:30 wangchunmei 阅读(196) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3