有没有一种方法可以比较一个数组和一个数组列表,比如
if (array[0]==arraylist[0])
Run Code Online (Sandbox Code Playgroud)
我正在解决这个问题:
String[] s= {"a","a","b","b","b","c"};
ArrayList<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
// create a new arraylist that stores the frequency of each character.
// For example, "a" appears twice in s, so newArrayList[0]=2; "b" appears
// three times, so newArrayList[1]=3, and so on.
Run Code Online (Sandbox Code Playgroud)
我的想法是使用循环来扫描字符串数组,并且每次当其中的字母等于列表中的字母时,int count++。但我不知道如何比较数组中的内容和数组列表中的内容。