[問題] JAVA的call by value
小弟我想要做一個問題
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)
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 7 篇):