伙计们我在使用java时有点新,而且我正在尝试编写一个程序,它将检查2d数组是否包含1d数组的值。第二个数组类似于数字列表,它将检查第一个数组是否匹配。在Java中将2d数组与1d进行比较
array1[6]= {"a","b","c","d","e","f"}
array2[1][4]={{"a","b","c","d"}{"d","e","f","g"}}
array2[0]= rowcomplete ; // because it contain all the value a,b,c,d
array2[1]= incomplete; // because it only match d,e,f but not g
这是我的代码:
String array1[] = {"a","b","c","d","e","f"};
String array2[][] = {{"a","b","c","d"}, {"d","e","f","g"}};
for (int 2row = 0; 2row < array2.length; 2row++) {
for (int 2column = 0;2column< array2[2row].length;2column++) {
for(int 1row=0; 1row < array1[1row].length();1row++) {
if (array2[2row][2column].equals(array1[1row])) {
System.out.println("complete");
}
else{
}
}
}
}
为什么所有的变量都以数字开始?它不会编译。 –
哦!对不起我的错误,也是array1 [] = {“a”,“b”,“c”,“d”,“e”,“f”}和array2 [] [] = {{“a” ,“c”,“d”} {“d”,“e”,“f”,“g”}} – user1030431