環,我可以從string [] array
像這樣的例子進行個別strings
:的Android與String []數組
//first, make stringArray1 the same size as arrayList1
stringArray1 = new String[arrayList1.size()];
//stringArray1 will contain all the values in arrayList1
stringArray1 = arraylist1.toArray(stringArray1);
//for each value in stringArray1 make it into an individual string,
//called string1
for(String string1: stringArray1)
{
System.out.println("string1 is " + string1);
}
你能告訴我怎麼會把另一個字符串轉換,從string [] array
到同一for
循環? arrayList1
和arrayList2
的尺寸完全相同。我以爲我能夠使用&&
但沒有喜悅。我得到'Expression expected'
。或者我需要有兩個不同的for
循環? 這是我有:
//first, make stringArray1 the same size as arrayList1
stringArray1 = new String[arrayList1.size()];
//second, make stringArray2 the same size as arrayList2
stringArray2 = new String[arrayList2.size()];
//stringArray1 will contain all the values in arrayList1
stringArray1 = arraylist1.toArray(stringArray1);
//stringArray2 will contain all the values in arrayList2
stringArray2 = arraylist2.toArray(stringArray2);
//for each value in stringArray1 make it into an individual string,
//called string1. Do likewise for string2
for(String string1: stringArray1 && String string2: stringArray2)
{
System.out.println("string1 is " + string1);
System.out.println("string2 is " + string2);
}
這是行不通的。每個循環有兩個或將數組收集到一箇中。 –
另外從兩個陣列可以有不同的大小。然後每個循環都無法處理。 –
@ MuratK.Thanks評論,兩個陣列將是完全相同的大小。 – CHarris