class prog{
String a[]={"manu is a good girl"};
int count=0;
public void cal1(String search){
int i;
// String s=search;
for(i=0;i<=14;i++){
if(charAt(i)=='a'){
count++; }
}
System.out.println("count:"+count);
}
}
class p3{
public static void main(String ar[]){
prog obj=new prog();
obj.cal1(ar[0]);
}
}
in the above program the following errors are coming: p3.java:8:cannot find symbol symbol:method charAt(int) location:class prog if(charAt(i)=='a'){
But the syntax of the charat()function is correct in the code.
Hi Friend,
Try the following code:
class prog{
int count=0;
public void cal1(String search){
int i;
String s=search;
for(i=0;i<s.length();i++){
if(s.charAt(i)=='a'){
count++;
}
}
System.out.println("count:"+count);
}
}
class p3{
public static void main(String ar[]){
prog obj=new prog();
obj.cal1(ar[0]);
}
}
Thanks