关于字符串统计对数的问题
package javaapplication4;
public class Main {
public static void main(String[] args) {
String s="",cc;
int v=0,c=0;
s="want you to know one thing";
cc=s.substring(1,2);
for(int i=1;i<s.length();i++)
{
if(s.substring(i-1,i)=="n") v=v+1;
if(s.substring(i-1,i)=="c") c=c+1;
}
System.out.print(c+" "+ v+" "+cc);
}
}