『壹』 java鎬庝箞鍒犻櫎鑻辨枃鏍囩偣絎﹀彿
綰犳d笅錛宼oString鏂規硶鏄鐢ㄦ潵杞鎹涓瀛楃︿覆鐨勶紝涓嶈兘鐢ㄤ簬瀛楃︿覆鎴鍙栫殑銆傚彲浠ラ氳繃鍒ゆ柇鏄涓嶆槸瀛楁瘝錛屽傛灉鏄瀛楁瘝鐨勮瘽錛屽氨淇濈暀涓嬫潵錛屽尯鍩熺殑鐩存帴蹇界暐鎺夊嵆鍙銆
public
static
String
getString(String
src)
{//杈撳叆鍙傛暟涓虹浉搴旂殑瀛楃︿覆
char[]
cr=
src.toCharArray();
char[]
str=
new
char[cr.length];
int
index
=
0;
for(char
newchar
:
cr)
{
if((newchar
<=
'Z'
newchar>=
'A')
||
(newchar
<=
'z'
newchar>=
'a'))
{//鍒ゆ柇鏄涓嶆槸瀛楃
str[index
++]
=
c;
}
}
return
new
String(str,
0,
index);//榪斿洖瀛楃︾粨鏋
}