GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — think-in-java/12.6 练习.md at master · chenpengcode/think-in-java

Expand file tree

/

12.6 练习.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
9 lines (7 loc) · 1.34 KB
/

12.6 练习.md

Copy path

File metadata and controls

9 lines (7 loc) · 1.34 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

12.6 练习

12.6 练习 (1) 创建一个myString类,在其中包含了一个String对象,以便用在构建器中用构建器的自变量对其进行初始化。添加一个toString()方法以及一个concatenate()方法,令其将一个String对象追加到我们的内部字串。在myString中实现clone()。创建两个static方法,每个都取得一个myString x句柄作为自己的自变量,并调用x.concatenate("test")。但在第二个方法中,请首先调用clone()。测试这两个方法,观察它们不同的结果。 (2) 创建一个名为Battery(电池)的类,在其中包含一个int,用它表示电池的编号(采用独一无二的标识符的形式)。接下来,创建一个名为Toy的类,其中包含了一个Battery数组以及一个toString,用于打印出所有电池。为Toy写一个clone()方法,令其自动关闭所有Battery对象。克隆Toy并打印出结果,完成对它的测试。 (3) 修改CheckCloneable.java,使所有clone()方法都能捕获CloneNotSupportException违例,而不是把它直接传递给调用者。 (4) 修改Compete.java,为Thing2和Thing4类添加更多的成员对象,看看自己是否能判断计时随复杂性变化的规律——是一种简单的线性关系,还是看起来更加复杂。 (5) 从Snake.java开始,创建Snake的一个深层复制版本。

You are visitor 01402877 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.