1要求就是  比如说  aa  ss  ss  cc  nmik   ssd  klkl ss  dd  然后查出里面出现ss的次数   这个怎么做啊
  不要是四的  要活的 就是你不管我输入什么  都可以 但是要判断里面的个数

解决方案 »

  1.   

    将输入的字符串用 split(" ");
    然后就遍历比较就好了啊。
      

  2.   

    不要是四的 要活的 就是你不管我输入什么 都可以 但是要判断里面的个数
    这句话不理解。。String str = "aa ss ss cc nmik ssd klkl ss dd ";
    String strTemp = str.replaceAll("ss", "");
    System.out.println((str.length()-strTemp.length())/"ss".length());
      

  3.   

    System.out.print("请输入语句:");
    BufferedReader input=new BufferedReader(new InputStreamReader(System.in));   // BufferedReader字符读取文件
    String statement=input.readLine();
    int l=0;
    int count=1;
    boolean t=false;
    String tmp="";
    for(int s=0;s<statement.length();s++){
    String sub=statement.substring(s,s+1);
    if(!sub.equals(" ")){
    tmp+=sub;
    }
    }

    l=tmp.length();
    String c[]=new String[l];
    for(int i=0;i<l;i++){
    c[i]=tmp.substring(i,i+1);
    }
    for(int b=0;b<l;b++){

    for(int e=0;e<b;e++){

    if(c[b].equals(c[e])){
    t=true;
    }
    }
    if(t==false){

    for(int d=b+1;d<l;d++){
    if(c[b].equals(c[d])){
    count++;
    }
    }
    System.out.println(c[b]+"字符共出现了"+count+"次");
    count=1;
    }
    t=false;
    }
    }
     比如我写的这个 我想你们帮改哈 改成查询一个 不是单一的一个字母 我是查的不是单一的一个字母, 查询用空格隔开的  比如:  aa  aa  bb  ss  我想查的是aa出现的次数   而不是a出现的次数  就这个意思
      

  4.   

    你要查ss,但是sss的话算几个?
      

  5.   

    /**
     * 
     */
    package com.test;/**
     * 
     * Copyright: Copyright (c) 2010 Shenzhen Taiji Software Corparation 
     * abc.java
     * 
     * @author 邹瑞金
     * @version 1.0
     * @date 2012-1-13 上午11:17:35
     */
    public class abc { /**
     * @param args
     */
    public static void main(String[] args) {
    String s = "aa ss ss cc nmik ssssd klkl ss dd";
    String [] arrChars = s.split("ss");
    System.out.println(arrChars.length-1); }}
      

  6.   

    强大那样哦 这个 不是那样的啊
      package yym;import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;public class www {
    public static void main(String[] args) throws IOException {
    System.out.print("请输入语句:");
    BufferedReader input=new BufferedReader(new InputStreamReader(System.in));   // BufferedReader字符读取文件
    String statement=input.readLine();
    int l=0;
    int count=1;
    boolean t=false;
    String tmp="";
    for(int s=0;s<statement.length();s++){
    String sub=statement.substring(s,s+1);
    if(!sub.equals(" ")){
    tmp+=sub;
    }
    }

    l=tmp.length();
    String c[]=new String[l];
    for(int i=0;i<l;i++){
    c[i]=tmp.substring(i,i+1);
    }
    for(int b=0;b<l;b++){

    for(int e=0;e<b;e++){

    if(c[b].equals(c[e])){
    t=true;
    }
    }
    if(t==false){

    for(int d=b+1;d<l;d++){
    if(c[b].equals(c[d])){
    count++;
    }
    }
    System.out.println(c[b]+"字符共出现了"+count+"次");
    count=1;
    }
    t=false;
    }
    }
    }应该是这样的
      

  7.   

     BufferedReader input=new BufferedReader(new InputStreamReader(System.in));      String content=input.readLine();
          
     String [] arrayContent = content.split("ss");
     
     System.out.println(arrayContent.length-1);
      

  8.   

    还是直接利用Java已经提供的函数来直接实现目标比较方便。2楼和5楼的都比较不错。自我检讨下。
      

  9.   

    再来import java.io.Console;/**
     * 
     * Copyright: Copyright (c) 2010 Shenzhen Taiji Software Corparation 
     * abc.java
     * 
     * @author 邹瑞金
     * @version 1.0
     * @date 2012-1-13 上午11:17:35
     */
    public class abc { /**
     * @param args
     */
    public static void main(String[] args) {

    //String s = "aa ss ss cc nmik ssssd klkl ss dd";
    Console console = System.console();
     if (console != null) {  
    String s = new String(console.readLine("请输入你的字符:"));
    s = " " + s +" ";
    String [] arrChars = s.split("ss");
    System.out.println(arrChars.length-1);
     }else {          
       System.out.println("Console is unavailable.");    
            }        }}
      

  10.   

    你是要按照字符来判断出现次数吗?public class test {
    public static void main(String[] args) {
    String s = "aa ss ss cc nmik ssd klkl ss dd";
    System.out.println(findHit(s,"ss"));
    }

    public static int findHit(String str,String pattern) {
    int hit = 0;

    int pos = -1;

    do {
    pos = findStrPos(str, pattern, pos+1);
    if(pos != -1)
    ++hit;
    } while(pos != -1 && pos < str.length()); 

    return hit;
    }

    public static int findStrPos(String str,String pattern,int fromindex) {
    return str.indexOf(pattern, fromindex);
    }
    }