一、"类"嵌套的情景演示
二、给"MobilePhoneConfiguration
"初始化值
三、思想解析:
四、"嵌套类"的代码块
class MobilePhoneConfiguration {
private String phoneMobile;
private String phoneType;
private String phoneOperatingSystem;
private int phonePrice;
private int phoneInternal;
private PhoneFunction phoneFunction;
public MobilePhoneConfiguration(String phoneMobile,
String phoneType, String phoneOperatingSystem,
int phonePrice, int phoneInternal,
PhoneFunction phoneFunction) {
this.phoneMobile = phoneMobile;
this.phoneType = phoneType;
this.phoneOperatingSystem = phoneOperatingSystem;
this.phonePrice = phonePrice;
this.phoneInternal = phoneInternal;
this.phoneFunction = phoneFunction;
}
@Override
public String toString() {
return "MobilePhoneConfiguration{" +
"phoneMobile='" + phoneMobile + '\'' +
", phoneType='" + phoneType + '\'' +
", phoneOperatingSystem='" + phoneOperatingSystem + '\'' +
", phonePrice=" + phonePrice +
", phoneInternal=" + phoneInternal +
", phoneFunction=" + phoneFunction +
'}';
}
public String getPhoneMobile() {
return phoneMobile;
}
public void setPhoneMobile(String phoneMobile) {
this.phoneMobile = phoneMobile;
}
public String getPhoneType() {
return phoneType;
}
public void setPhoneType(String phoneType) {
this.phoneType = phoneType;
}
public String getPhoneOperatingSystem() {
return phoneOperatingSystem;
}
public void setPhoneOperatingSystem(String phoneOperatingSystem) {
this.phoneOperatingSystem = phoneOperatingSystem;
}
public int getPhonePrice() {
return phonePrice;
}
public void setPhonePrice(int phonePrice) {
this.phonePrice = phonePrice;
}
public int getPhoneInternal() {
return phoneInternal;
}
public void setPhoneInternal(int phoneInternal) {
this.phoneInternal = phoneInternal;
}
public PhoneFunction getPhoneFunction() {
return phoneFunction;
}
public void setPhoneFunction(PhoneFunction phoneFunction) {
this.phoneFunction = phoneFunction;
}
}
//-------------------------------------------------------
class PhoneFunction {
private String phoneCall;
private String phoneGame;
private String phoneMusic;
public PhoneFunction(String phoneCall, String phoneGame, String phoneMusic) {
this.phoneCall = phoneCall;
this.phoneGame = phoneGame;
this.phoneMusic = phoneMusic;
}
@Override
public String toString() {
return "PhoneFunction{" +
"phoneCall='" + phoneCall + '\'' +
", phoneGame='" + phoneGame + '\'' +
", phoneMusic='" + phoneMusic + '\'' +
'}';
}
public String getPhoneCall() {
return phoneCall;
}
public void setPhoneCall(String phoneCall) {
this.phoneCall = phoneCall;
}
public String getPhoneGame() {
return phoneGame;
}
public void setPhoneGame(String phoneGame) {
this.phoneGame = phoneGame;
}
public String getPhoneMusic() {
return phoneMusic;
}
public void setPhoneMusic(String phoneMusic) {
this.phoneMusic = phoneMusic;
}
}
//-------------------------------------------------------
class TestMobilePhoneConfiguration {
public static void main(String[] args) {
MobilePhoneConfiguration mobilePhoneConfiguration[] = new MobilePhoneConfiguration[3];
//初始化过程
mobilePhoneConfiguration[0] = new MobilePhoneConfiguration("XiaoMi",
"Utral",
"安卓系统",
4000,
128,
new PhoneFunction("打电话", "打游戏", "听音乐"));
mobilePhoneConfiguration[1] = new MobilePhoneConfiguration("HuaWei",
"Utral",
"鸿蒙系统",
8000,
256,
new PhoneFunction("打电话", "打游戏", "听音乐"));
mobilePhoneConfiguration[2] = new MobilePhoneConfiguration("Apple",
"IOS系统",
"苹果",
5000,
256,
new PhoneFunction("打电话", "打游戏", "听音乐"));
System.out.println("手机配置:");
for (MobilePhoneConfiguration m : mobilePhoneConfiguration) {
System.out.println(Arrays.asList(m));
}
}
}
标签:初始化,return,String,phoneInternal,PhoneFunction,理解,phoneMusic,public
From: https://www.cnblogs.com/chen-zhou1027/p/16953859.html