2 11練習 練習5(1) p37

2021-06-26 17:12:10 字數 625 閱讀 3877

練習(5):(1)修改前乙個練習,將dataonly中的資料在main()方法中賦值並列印出來。

public class dataonlytest

dataonly data = new dataonly();

data.i = 47;

data.d = 1.1;

data.b = false;

system.out.println("data.i = "+data.i);

system.out.println("data.d = "+data.d);

system.out.println("data.b = "+data.b);

}}

問題:不明白為什麼在main()主函式中定義類呢?按照物件導向的思想,這樣豈不是很不合理?

方法二:

public class dataonlytest

} dataonly data = new dataonly();

data.i = 47;

data.d = 1.1;

data.b = false;

data.show();

}}

練習2 11 練習2 20

1.練習2.11 define mul interval x y let x1 lower bound x x2 upper bound x y1 lower bound y y2 upper bound y let zzx and x1 0 x2 0 zzy and y1 0 y2 0 fzx a...

python學習練習

1.猜數字遊戲 d python coding utf 8 2019 4 14 10 29 n 1tuichu 1 import random print 20,讓我們一起來玩遊戲吧 20,sep n end n rnum random.randint 1,100 while 1 1 num int...

寫個核心鍊錶,練習練習

立下此碼,過段時間再看是否有進步 include include malloc h struct list define list init head head next head head prev head void list add struct list new struct list pr...