我想弄明白在另一個類中引用數組,並有很多樂趣。任何人都可以幫忙..?這是代碼。ref從另一個類的數組
據我瞭解,吸氣getName
正在爲一個字符串,但我不知道如何引用數組與吸氣aff_array[] get afz()
public class aff_array { String name; aff_array[] afz;
public aff_array[] getAfz() {
return afz;
}
public String getName() {
return name;
}
public static void main (String[] args) {
int z = 3; //total no of affirmations
int x = 1;
aff_array[] afz = new aff_array[z]; //dim
while (x < z) {
afz[x] = new aff_array(); // create objects for array
x = x + 1;
}
afz[1].name = "i am the best";
afz[2].name = "you are the rest";
}
這是其他類,並在那裏我想要的數組值更換aff_array.class.getName()
與aff_array[] getAfz()
但我不知道該怎麼做或引用afz(1)
例如(getName
工作)
public void onReceive(Context context, Intent intent)
{
setNotification(context, aff_array.class.getName());
WakeLocker.acquire(context);
Toast.makeText(context,"One shot alarm received. No more toasts will be shown.", Toast.LENGTH_SHORT).show();
WakeLocker.release();
}
感謝 - 它編譯但崩潰 – sunirmalya
崩潰?運行時錯誤?如果它的ArrayIndexOutOfBounds,那麼你需要自己理解或者告訴錯誤信息 –
它似乎是空的 - 我很抱歉 - 我會繼續尋找謝謝 – sunirmalya