To my understanding you need to count occurrences of a character in a string.If that's the case here is an example. there is no need to convert it to char array
public class Test {
public static void main(String[] args) {
String x="dhakjkfhajfhuagjkadmnfd";
String y="tskashguadmnsdm,as";
String Check_Character="s";
//Availability
System.out.println("X has Check_Character :"+x.contains(Check_Character)); //false
System.out.println("Y has Check_Character :"+y.contains(Check_Character));//true
//Number of occurrences
System.out.println("X has Check_Character :"+((x+" ").split(Check_Character).length-1)+" : times");//0 times
System.out.println("Y has Check_Character :"+((y+" ").split(Check_Character).length-1)+" : times");//4times
}
}
Otherwise you can use a list instead of an array or use this.
String z="dhakjkfhajfhuagjkadmnfd";
char c[]=z.toCharArray();