从Method方法到Classes.pptVIP

  • 1
  • 0
  • 约7.96千字
  • 约 36页
  • 2017-08-27 发布于上海
  • 举报
this 關鍵字 可以透過 this,呼叫相同類別底下的另一個建構元 public class AClass { private int x, y; private int width, height; public AClass(){ this(0,0,0,0); } public AClass(int width, int height){ this(0,0,width,height); } public AClass(int x, int y, int width, int height){ this.x = x; this.y = y; this.width = width; this.height = height; } ... } this 關鍵字 具有二個建構元的 Box 類別 class Box { double width, height, depth; // 預設的建構元 Box() { this(1, 2, 3); } // 可以自行指定長寬的建構元 Box(int width, int height, int depth){ this.width = width; this.height = height; this.depth = depth; } } this 關鍵字 Exam

文档评论(0)

1亿VIP精品文档

相关文档