去除字符串s1中包含的s2中的字符后输出s1

来源:互联网 发布:淘宝品牌女装代理 编辑:程序博客网 时间:2024/04/29 08:09

对于 s1   They arestudents.    和s2    aeiou ;去掉s1中包含的s2中的字符,输出Thy r stdnts.


public class subString{

    public static void main(String[] args){

        Strings1= "They are students.";

        Strings2="aeiou";

        boolean[] array=new boolean[128];//标准ASCII码有128个,包括空格

        for(int i=0; i< s2.length();++i){

            array[s2.charAt(i)]=true;

        }

        for(int i=0;i<s1.length();++i){

            if(array[s1.charAt(i)]==false)

                System.out.print(s1.charAt(i));

        }

    }

}


0 0
原创粉丝点击