ArrayList<String> mylist = new ArrayList<String>();
build2 = "";
String[] source = file2.split(" ");
for(int i = 0; i < source.length; i++){
int offset = mylist.indexOf(source[i]);
if(Arrays.asList(source).equals(mylist)){
build2 += (char)(65 + offset);
}
}
System.out.println("\nYour decrypted message is: \n" + build2);
这是一个加密和解密项目。现在,字符串数组mylist包含一堆用于扑克牌的unicode。我的数组来源包含扑克牌和号码。
我想检查一下,如果阵列中有扑克牌,然后显示-
build2 + =(字符)(65 +偏移量); (将某些扑克牌转换为字母)
我的完整代码在这里-
https://repl.it/@MatthewZeman/DecryptionCode
https://repl.it/@MatthewZeman/EncryptionCode
输入-
🃁 36 🂱 36 🂡
输出-
ABC
最佳答案
我认为您正在寻找List.containsAll()。
List.equals()仅在两个列表包含相同顺序的相同元素时才返回true。
如果要检查两个列表中是否都包含所有元素:
if(Arrays.asList(source).containsAll(mylist)){
build2 += (char)(65 + offset);
}