Java 7 for Absolute Beginners/Java 7基礎教程--代碼糾錯
中文版書中的問題代碼記錄:
只記錄了P213后面的錯誤代碼,如果后面發現P213頁前面的錯誤代碼,會繼續補齊。但我提供的代碼都是可以正常運行的,如果有使用者發現中文版書中其他的錯誤代碼請告訴我,方便我在這里補齊,謝謝。
P213,重構代碼有誤,作者在源代碼中提供的正確代碼如下:
public ShootingGalleryTargetRow(Image sprite, int value) { targetValue = value; newTargetTicker = 0; this.sprite = (BufferedImage)sprite; }
P220,函數中的System.exit(1)因為前面拋出了異常,所以永遠無法執行,直接刪除。
public Image getSpriteBySize(int size) { ...
throw new IllegalArgumentException("Unknown Sprite Size: " + size); System.exit(1); ... }
P250,使用泛型GenericRole<String, String>未定義類型。
public class GenericRoleProgram { public static void main(String[] args) { LinkedList<GenericRole<String,String>> roleMap=new LinkedList<GenericRole<String, String>>(); ... }
posted on 2017-08-05 12:15 zYx.Tom 閱讀(632) 評論(0) 編輯 收藏 所屬分類: 1.Java世界