実験課題4

Exercise 4(課題4) See the section 4.3.1. "Data Abstraction and Encapsulation". Show the source code to use static member of below figure and its execution result as a screenshot. Follow instructions below to show the result.

  1. create the Java application project named chapter4kadai4.
  2. add the project chapter4kadai3 to chapter4kadai4.
  3. create Cache class such as below figure in the project chapter4kadai4.
  4. modify the source code of figure 12 to store the familyName data to static member Cache.name in setUserName method of Cache class
  5. take the screenshot of the execution result.
public class Cache {

	public static String name = "";
}
Figure:`Cache` class has a static member

(4.3.1.節をよく読み、図に示すCacheクラスをプロジェクトchapter4kadai3に追加し、図12のUserクラス内のsetUserNameメソッド内で、setUserNameメソッドを実行するたびにfamilyNameを、Cacheクラスの静的メンバーであるCache.nameフィールドに保存するように改変し、ソースコードを報告しなさい。)