JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 為何用System.console()去取得物件卻取不到
zhong4





發文: 21
積分: 0
於 2011-10-08 03:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
為何我用我家的電腦跑,如下的程式碼,卻一直沒辦法取得console的實體.

輸出結果為:無法取得console實體

1
2
3
4
5
6
7
8
9
10
11
12
public class Main {
    public static void main(String[] args) {
       Console c=System.console();
       if(c==null){
      System.out.print("無法取得console實體");
      return;
       }
       String username=c.readLine("Enter username: ");
       System.out.print(username);
    }
 
}


reply to postreply to post
作者 Re:為何用System.console()去取得物件卻取不到 [Re:zhong4]
caterpillar

良葛格

版主

發文: 2613
積分: 70
於 2011-10-08 06:38 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不是每個環境下都有 Console 的:
Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked.....


reply to postreply to post
良葛格學習筆記
» JWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8