zoukankan      html  css  js  c++  java
  • 《Java实战开发经典》第五章5.3

    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+"次");
        }
    }
    
  • 相关阅读:
    forget word out4
    forget word out2
    forget words out1
    en_o out1
    en_e outtest2
    en_e out1
    疑难en_a
    en_a
    entest1
    铺音out2
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/6992676.html
Copyright © 2011-2022 走看看