package xiti5;
public class Third {
public static void main(String[] args) {
T t=new T("want you to know one thing ");
t.tell();
}
}
class T{
private String str;
public T(String str){
this.str=str;
}
public void tell(){
char c[]=str.toCharArray();//将字符串分解为字符数组
int n=0;
int m=0;
for(int i=0;i<c.length;i++){
if(c[i]=='n'){
n++;
}else
if(c[i]=='o'){
m++;
}
}
System.out.println("该字符串中n出现了"+n+"次,o出现了"+m+"次");
}
}