[問題] static method

看板java作者 (無)時間19年前 (2006/06/19 17:33), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/8 (看更多)
public class test { public static void main(String args[]) { System.out.print(more(2,4,4,4)); } public static int more(int... num) { int total=0; for(int a:num) total+=a; return total; } } 為什麼在class test底下 more method一定要加static 才能給過? 而其他class則不需用呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.221.120.127
文章代碼(AID): #14bcz_TZ (java)
討論串 (同標題文章)
文章代碼(AID): #14bcz_TZ (java)