阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】StringEditor类的功能是:已
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。
【说明】StringEditor类的功能是:已知一个字符串,返回将字符串中的非字母字符都删除后的字符串。
public (1) {
public static String removeNonLetters( (2) ){
StringBuffer aBuffer=(3);
char aCharacter;
for(int i=0; i<original.length();i++){
aCharacter=(4);
if(Character.isLetter(aCharacter))
aBuffer.append( (5) );
}
return new String(aBuffer);
}
}
public class StringEditorTester{
public static void main(String args[]){
String riginal="Hi!, My Name is Mark, 234I think you are my classmate?!!";
System.out.println(StringEditor.removeNonLetters(original));
}
}
(1)class StringEditor (2)String original (3)new StringBuffer(original.length()) (4)original.charAt(i) (5)new Character(aCharacter) 解析:(1)class StringEditor
类StringEditor的头部。
(2)String original
StringEditor类的方法removeNonLetters的形参是String类型。
(3)new StringBuffer(original.length())
动态生成一个StringBuffer类对象,长度是形参字符串original的长度。
(4)original.charAt(i)
取original字符串的第i个字符。
(5)new Character(aCharacter)
将生成一个字母字符,值为aCharacter,添加到字符串aBuffer的尾部。
I am looking forward to your reply that will be h 英语 2020-04-05 …
我这样写对吗:I got a cold.I would like to take a sick l 其他 2020-05-14 …
补写对话:I'm4,_______.It's time for class .Let's5.___ 英语 2020-05-16 …
英文IChing谁能告诉我为什么我的一本书里把英文I-Ching解释为《易经》?我查了词典《易经》 其他 2020-05-20 …
1.Whatisfourandfive?It'snine.这样填写对吗?2.Theman'snam 英语 2020-05-22 …
Who's__,please?请在空格中填写.此句是电话里的对话.I'mafraidsheisn' 英语 2020-06-06 …
求各位好心善良的高人指点英语六级估分听力对十六个,填词对四个,句子没写对快速阅读总共对九个,错的是 其他 2020-06-07 …
我四级能考几分啊,过四级有戏吗快速阅读就对了四个~听力对话对12个短文对7个复合式听写词填对6个, 其他 2020-06-13 …
数学苦手问关于i(i是虚数单位)的问题.设z=1+i(i是虚数单位),则2/z(题目是上面2,下面i 数学 2020-11-06 …
英语句子我热爱体育运动怎么写?I'mgoingtoplayfootball对么?你们误解了...我热 英语 2021-02-05 …