[問題] JAVA的call by value

看板java作者 (ldg)時間19年前 (2007/03/24 22:03), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/7 (看更多)
小弟我想要做一個問題 class student{ static void print(){ ... } static number; public static void main(String[] args){ student[] s=new student[3]; int i; for(i=0;i<3;i++){ s[i]=new student(); s[i].number=i; } student.print(); } } 我希望可以印出每個student的number 但是不是設計instance method 而是希望利用一個static method 將整個s[]的num排版並印出來 在C語言的話是將s或&s傳入 但是在JAVA小弟不甚熟悉 可以幫小弟我開個頭嗎? 或是指導比較正確的想法 拜託了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.192.211.79 發現不能推文.. 順便請問一下 可以在main method裡面宣告static variable嗎? public static void main(String[] args){ static student[] s=new student[3]; } 這樣 一併謝謝 ※ 編輯: ldg 來自: 210.192.211.79 (03/24 22:09)
文章代碼(AID): #161I-R6p (java)
討論串 (同標題文章)
文章代碼(AID): #161I-R6p (java)