看板 java 關於我們 聯絡資訊
public class Prac { public static void main(String[] args) throws Exception{ int x = 6; Prac p = new Prac(); p.doStuff(x); System.out.println(" main x = " + x); } void doStuff(int x){ System.out.println(" doStuff x = " + x++); } } And the command-line invocations: javac Prac.java java Prac 5 -------------------------------------------------------------------- What is the result? Ans: B. An exception is thrown at runtime. 我自己原本是寫 C. doStuff x = 6 main x = 6 想請要一下, 是哪邊會丟出 runtime exception? 且是哪種exception? 我有試著自己跑過這個code, 但沒有看到錯誤訊息, 於是仍然困惑著 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.174.122 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1487597752.A.543.html ※ 編輯: uopsdod (180.217.174.122), 02/20/2017 21:36:16
haha02: 盡信書不如無書 02/20 22:35
qrtt1: 你的 code 跟你的問題對不上來 xd 02/21 08:10
uopsdod: 我想我是要確定誰對誰錯噢 沒有信書不信書的問題 02/21 23:48
eieio: 我用 https://www.codechef.com/ide 跑,你的答案正確啊 02/22 16:18
haha02: 跑下去的結果就是真正的答案啊 找個人同意才能讓說服自己 02/23 20:14
haha02: 的話會很辛苦喔 因為大部分孤狗到的資源都要自己辨別真偽 02/23 20:14
haha02: 這種很明顯是答案寫錯的就有自信一點吧 02/23 20:14
uopsdod: 資源本來就不嫌多。如果能多一個人討論那總是更好 02/25 06:33
uopsdod: Google資源本來就會用,也會自己辨真偽。但也不代表多問人 02/25 06:33
uopsdod: 不好是吧? 02/25 06:34
uopsdod: 感謝大家幫忙驗證 那我了解了 02/25 06:35