java.lang包下直屬類,從Java Platform Standard Edition 7 Documentation中一查便知:java
**Interfaces** Appendable AutoCloseable CharSequence Cloneable Comparable Iterable Readable Runnable Thread.UncaughtExceptionHandler **Classes** Boolean Byte Character Character.Subset Character.UnicodeBlock Class ClassLoader ClassValue Compiler Double Enum Float InheritableThreadLocal Integer Long Math Number Object Package Process ProcessBuilder ProcessBuilder.Redirect Runtime RuntimePermission SecurityManager Short StackTraceElement StrictMath String StringBuffer StringBuilder System Thread ThreadGroup ThreadLocal Throwable Void **Enums** Character.UnicodeScript ProcessBuilder.Redirect.Type Thread.State **Exceptions** ArithmeticException ArrayIndexOutOfBoundsException ArrayStoreException ClassCastException ClassNotFoundException CloneNotSupportedException EnumConstantNotPresentException Exception IllegalAccessException IllegalArgumentException IllegalMonitorStateException IllegalStateException IllegalThreadStateException IndexOutOfBoundsException InstantiationException InterruptedException NegativeArraySizeException NoSuchFieldException NoSuchMethodException NullPointerException NumberFormatException ReflectiveOperationException RuntimeException SecurityException StringIndexOutOfBoundsException TypeNotPresentException UnsupportedOperationException **Errors** AbstractMethodError AssertionError BootstrapMethodError ClassCircularityError ClassFormatError Error ExceptionInInitializerError IllegalAccessError IncompatibleClassChangeError InstantiationError InternalError LinkageError NoClassDefFoundError NoSuchFieldError NoSuchMethodError OutOfMemoryError StackOverflowError ThreadDeath UnknownError UnsatisfiedLinkError UnsupportedClassVersionError VerifyError VirtualMachineError **Annotation Types** Deprecated Override SafeVarargs SuppressWarnings
大致上按照上面的分類閱讀,估計應該學別人的體例-------關鍵代碼分析,加上編譯經過可運行的用例。類不少,源碼之間繼承關係也挺複雜,閱讀源碼計劃的開始階段我決定從簡單作起,今天閱讀第一個類Boolean:ide
一、Boolean是包裝類,包裝了基本數據類型boolean;ui
二、除非要求一個新的instance,Boolean的構造方法Boolean(boolean value)極少用,用靜態工廠方法valueOf(boolean value)來獲取一個Boolean實例,由於Boolean有兩個常量靜態成員TRUE和FALSE,valueOf(boolean value)是從常量池中取得類的實例,用源碼的話是「this method is likely to yield significantly better space and time performance.」。this
三、能夠借鑑的是hashCode()方法和equals(Object obj)方法,因爲只有兩個值Boolean的hashCode是寫定的,分別是1231和1237。spa