Java语言10(内部类、异常处理).pptVIP

  • 0
  • 0
  • 约1.06万字
  • 约 70页
  • 2017-10-03 发布于江西
  • 举报
Java语言10(内部类、异常处理).ppt

接口的一个实例 interface Animal { void eat(); void sleep(); } class Tiger implements Animal { public void eat() { System.out.println(Tiger eat); } public void sleep() { System.out.println(Tiger sleep); } } class TestAnimal { public static void main(String [] args) { Animal an=new Tiger(); an.eat(); an.sleep(); } } 形参为接口 static void printAnimal(Animal a) { a.eat(); a.sleep(); } 返回值为接口 static Animal getAnimal() { return new Tiger(); } 内部类 在一个类中定义另外一个类,这个类称为内部类、内置类、嵌入类。 内部类可以让我们在逻辑上相关的组织起来,并由外部类来控制内部

文档评论(0)

1亿VIP精品文档

相关文档