実験課題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.
- create the Java application project named
chapter4kadai4. - add the project
chapter4kadai3tochapter4kadai4. - create
Cacheclass such as below figure in the projectchapter4kadai4. - modify the source code of figure 12 to store the
familyNamedata to static memberCache.nameinsetUserNamemethod ofCacheclass - take the screenshot of the execution result.
public class Cache {
public static String name = "";
}
(4.3.1.節をよく読み、図に示すCacheクラスをプロジェクトchapter4kadai3に追加し、図12のUserクラス内のsetUserNameメソッド内で、setUserNameメソッドを実行するたびにfamilyNameを、Cacheクラスの静的メンバーであるCache.nameフィールドに保存するように改変し、ソースコードを報告しなさい。)