[問題] try-catch
do{
try{
System.out.println("Enter the server's IP:");
IP=in.next();
clientSocket = new Socket(IP, 8000); // (*)
connect=true;
}
catch(Exception e)
{
String errMsg=e.getMessage();
System.out.println(errMsg);
}
}while(!connect);
想請問
我在這個do-while之後要用clientSocket時
為什麼compiler會說她沒有initialize?
還有可以怎麼改正這問題?
另一個小問題
如果在(*)處
想要處理IP輸入錯誤(連不到正確server)
是不是Socket會自動throw Exception?
先謝啦
如果需要我排版 再通知
--
我的露天拍賣:
http://tinyurl.com/6z4rw7
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.169.26.47
※ 編輯: walm20 來自: 118.169.18.225 (11/08 15:54)
→
11/08 15:59, , 1F
11/08 15:59, 1F
→
11/08 16:37, , 2F
11/08 16:37, 2F
推
11/08 16:42, , 3F
11/08 16:42, 3F
→
11/08 16:43, , 4F
11/08 16:43, 4F
→
11/08 17:43, , 5F
11/08 17:43, 5F
※ 編輯: walm20 來自: 118.169.18.225 (11/08 17:55)
推
11/08 18:29, , 6F
11/08 18:29, 6F