6 回答
TA贡献1827条经验 获得超7个赞
final String[][] temp={ {"2"} ,{"d"},{"1","2"},{ "2" },
..
}
};
final Object[][] cmdGrps = { { "FTP_INIT", temp[0] },
{ "ACCT ", temp[1] }, { "APPE ", temp[2] },
..
};
TA贡献2003条经验 获得超2个赞
import java.util.ArrayList; import java.util.List;
public class KK { public static void main(String[] args) { // Object[][] actualResult = new Object[10][1]; // String[][] expectedResult = new String[5][1]; 这两句就相当于 Object[][] actualResult = { { "1","11" }, { "2","22" }, { "3","33" }, { "4","44" }, { "5","55" }, { "6","66" }, { "7","77" }, { "8","88" }, { "9","99" }, { "10","1010" } }; String[][] expectedResult = { { "1","11" }, { "2","22" }, { "3","33" }, { "4","44" }, { "5","55" } }; List list1 = new ArrayList(); List list2 = new ArrayList(); for (int i = 0; i < actualResult.length; i++) { for(int j=0;j<actualResult[i].length;j++) list1.add(actualResult[i][j]); // 它的第二维只有一个所以这里就不要用循环去取了 } for (int i = 0; i < expectedResult.length; i++) { for(int j=0;j<expectedResult[i].length;j++) //请不要再问[10][3]或[10][4]等类似的问题,use your head list2.add(expectedResult[i][j]); } System.out.println(list1.containsAll(list2)); } }
TA贡献1900条经验 获得超5个赞
static final Object[][] cmdGrps = { { "FTP_INIT", new Object[]{ "2" } },
{ "ACCT ", new Object[]{ "2" } }, { "APPE ", new Object[]{ "1", "2" } },
{ "CDUP", new Object[]{ "2" } }, { "CWD ", new Object[]{ "2" } }, { "DELE ", new Object[]{ "2" } },
{ "LIST", new Object[]{ "1", "2" } }, { "MKD ", new Object[]{ "2" } }, { "PASV", new Object[]{ "2" } },
{ "PASS ", new Object[]{ "2", "3" } }, { "PORT ", new Object[]{ "2" } },
{ "PWD", new Object[]{ "2" } }, { "QUIT", new Object[]{ "2" } }, { "RETR ", new Object[]{ "1", "2" } },
{ "RNFR ", new Object[]{ "3" } }, { "RNTO ", new Object[]{ "2" } }, { "REST ", new Object[]{ "3" } },
{ "RMD ", new Object[]{ "2" } }, { "SITE ", new Object[]{ "2" } },
{ "STOR ", new Object[]{ "1", "2" } }, { "SYST", new Object[]{ "2" } },
{ "TYPE ", new Object[]{ "2" } }, { "USER ", new Object[]{ "3", "2" } } };
添加回答
举报