This code is to get the occurrence of the characters in the Arraylist firlast but charAt can't be used and gives an error
The method charAt(int) is undefined for the type ArrayList<String>Java(67108964)
int len = firlast.size();
int count[] = new int[256];
for(int i = 0; i < len; i++)
count[firlast.charAt(i)]++;
char ch[] = new char[firlast.size()];
for (int i = 0; i < len; i++) {
ch[i] = firlast.charAt(i);
int find = 0;
for (int j = 0; j < i; j++) {
if (firlast.charAt(i) == ch[j])
find++;
}
if (find == 1)
System.out.println("occurence " + firstlast.charAt(i) + count[firstlast.charAt(i)]);
}
Output of the firlast array is [rj, yf, rC, ac, ps, ni, er, et, FT, ei]
I dont know what i did wrong. please point out where i did wrong.
firlastis anArrayListas stated in the introduction, thenfirlast.charAt(i)won't compile. Are you sure that this is the exact code you are executing? - If not, please refer to 'How to create a minimal reproducible example?'.The method charAt(int) is undefined for the type ArrayList<String>Java(67108964)