話說這回我真的從第一個程式開始記錄
不過很快這裡就會塞滿滿了吧?(攤手
如果我90%網誌都是這種東西相信會有人想咬我的......(逃

import java.io.BufferedReader;  
import java.io.IOException;        
import java.io.InputStreamReader;

/**用了Java.io.*所以在ZeroJudge會CE*/


/**
 *
 * 第一個Java Program:
 * 輸入一行字串並Enter,輸出"hello, 字串"並換行
 * 重複執行直到輸入時只有Enter就自動結束
 * @author Janet
 * @date 20090813 11:28
 *  
 */

public class HelloWorld {

    public static void main(String[] args) throws IOException {
        /**用BufferedReader裝飾加入緩衝區讀取功能
         * BufferedReader的readLine()可讀入一整行字元以字串型式返回*/
        BufferedReader inbuf = new BufferedReader(new InputStreamReader(System.in));
        String data;
        
        /**判定非輸入終止,有讀到東西則迴圈進行*/
        while( ( data=inbuf.readLine() )!=null && data.length()!=0  ) {
            System.out.printf("hello, %s\n",data);
        }

    }

}

/**
 * 執行結果
 * 正確
 * 鍵盤僅輸入Enter時終止
 * */

文章標籤
全站熱搜
創作者介紹
創作者 jaacnaett 的頭像
jaacnaett

以歌者之名流浪                         <embed src="http://www.clocklink.com/clocks/0031-black.swf?TimeZone=CCT&" width="65" height="65" wmode="transparent" type="application/x-shockwave-flash">

jaacnaett 發表在 痞客邦 留言(1) 人氣(99)