public class Test5 {
public static void main(String args[]){
String message = "台南資訊展98年1月8日至13日";
int index=0;
// while ( index < message.length()) {
//取得字串長度( 用length() )
// if( (int)message.charAt(index) >=48 && (int)message.charAt(index) <=57 ){
// System.out.print(message.charAt(index));//charAt()取得第x個字元,由0開始。
// }
// index++;
// }
for (index =0 ; index< message.length(); index++){
if( (int)message.charAt(index) >=48 &&
(int)message.charAt(index) <=57 ){
System.out.print(message.charAt(index));
}
}
System.out.println("");
}
}
由於我不太會改blogspot的template,超過頁面的部份請點html原始碼起來看吧!
2009年1月14日 星期三
Java小練習(8)
本程式需要取出一字串內的某些文字。
取出"台南資訊展98年1月8日至13日"
將數字提取出來,不要文字。
#######source code starts ######################
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言