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

  • Post author:
  • Post category:其他


对于

s1


They arestudents.    和s2


aeiou

;去掉s1中包含的s2中的字符,输出Thy r stdnts.



public


class


subString{



public


static


void


main(String[]

args

){

String

s1

=

“They are students.”

;

String

s2

=

“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

));

}

}

}



版权声明:本文为chenyx90原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。