有人知道爲什麼不能編譯?將2維數組與Java中的單維數組進行比較
public class ArrayCompare{
public static void main (String []args){
String words= "Hello this is a test";
String delimiter=" ";
String [] blocker=words.split(delimiter);
String [][] grid= new String [100][100];
grid[0]="Hello";
if (grid[0].equals(blocker[0])){
System.out.print("Done!");
}
}
}
我想用2維數組來執行這個比較函數。我是新手!如果可以的話請幫忙。提前致謝!
'grid [0]'是字符串數組。將字符串分配給字符串數組是不可能的。 – turbanoff 2012-03-30 03:51:04
你想比較網格中的每個字符串到攔截器[i]嗎?如果是這樣,你需要一個嵌套循環 – 2012-03-30 03:51:43
我想測試每個字符串在網格中阻塞[i]。 – user1299661 2012-03-30 04:03:25