class?Simple{
private?int?IntValue;
private?double?DoubleValue;
private?String?StrValue;
public?int?getIntValue()?{
return?IntValue;
}
public?void?setIntValue(int?intValue)?{
IntValue?=?intValue;
}
public?double?getDoubleValue()?{
return?DoubleValue;
}
public?void?setDoubleValue(double?doubleValue)?{
DoubleValue?=?doubleValue;
}
public?String?getStrValue()?{
return?StrValue;
}
public?void?setStrValue(String?strValue)?{
StrValue?=?strValue;
}
}
public?class?TestSimple?{//測試類的
public?static?void?main(String[]?args)?{
//創建Simple類的對象aSimple
Simple?aSimple?=?new?Simple();
//set方法分別對對象的各個屬性設置具體的值
aSimple.setIntValue(5);
aSimple.setDoubleValue(123.45D);
aSimple.setStrValue("string?value?for?simple");
//get方法將aSimple的具體的值輸出在屏幕上
System.out.println("運行的結果如下:");
System.out.println("int?value?for?simple?is:?"?+?aSimple.getIntValue());
System.out.println("double?value?for?simple?is:?"?+?aSimple.getDoubleValue());
System.out.println("String?value?for?simple?is:?"?+?aSimple.getStrValue());
}
}
不知道是不是這樣的?