So here\'s the code I\'ve got so far...
import java.util.Scanner;
class count{
public static void main(String args[]){
Scanner s=new Scanner(Syst
the variable count needs the value to be reset after every iteration of k so it will look like this
for(int j= 0;j<=len-1;j++){
for(int k=0;k<=len-1;k++){
if(ch[j]==ch[k]){
arr[j]= count++;
}
}count=1;
}
moreover when you are trying to find the maximum in the array it would be easier and correct in this.
int max=0;
for(int z=1;z<=len-1;z++){
if(arr[z]>arr[max])
max=z;
}
what you are doing (rather what it would have done had count been reset) is storing the occurrence count of first character and then comparing it with the no. of occurrences of last character and if more then last character occurrences with itself.