《Java技术手册(第6版)》的原文摘录

  • The use of public static fields that are not final is almost never a good practices --- as multiple threads could update the field and cause behavior that is extremely hard to debug. (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • Field declarations are not part of any method. Instead, the Java compiler generates initialization code for the field automatically and puts it into all the constructors for the class. The initialization code is inserted into a constructor in the order in which it appears in the source code, which means that a field initializer can use the initial values of any fields declared before it. (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • Java generates a class initialization method automatically for every class. Class fields are initialized in the body of this method. Class fields are initialized in the body of this method, which is invoked exactly once before the class is first used(often when the class is first loaded by the Java VM). (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • The body of each initializer block is incorporated into the class initialization method, along with any static field initialization expressions. A static initializer is like a class method in that it cannot use the this keyword or any instance fields or instance methods of the class. (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • class methods can be hidden by a subclass but not overridden (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • Default access is more restrictive than protected --- as default access does not allow access by subclasses outside the package. Java packages do not "nest", so javanut6.ch03.different is just a different package than javanut6.ch03; it is not contained inside it or related to it in any way. (查看原文)
    1赞 2016-10-08 23:21:53
    —— 引自第23页
  • If a member of a class is declared protected, it is accessible to all classes within the package (the same as the default package accessibility) and also accessible within the body of any subclass of the class, regardless of the package in which that subclass is defined. If a member of a class is not declared with any of these modifiers, it has default access (sometimes called package access) and it is accessible to code within all classes that are defined in the same package but inaccessible outside of the package. (查看原文)
    vancexu 2015-05-13 07:43:22
    —— 引自第123页
  • The JVM is a program that provides the runtime environment necessary for Java programs to execute. (查看原文)
    2016-10-07 17:44:52
    —— 引自章节:Introduction to the Java Envir
  • Java 1.0 (1996) 212 classes in eight packages Java 1.1 (1997) Java 1.2 (1998) Java 1.3 (2000) Java 1.4 (2002) Java 5 (2004) generic types, enumerated types (enums), annotations, varargs methods, auto boxing, and a new for loop. Include 3562 classes and interfaces in 166 packages. Java 6 (2006) Java 7 (2011) Java 8 (2014) (查看原文)
    2016-10-07 17:44:52
    —— 引自章节:Introduction to the Java Envir
  • In the early days of the platform, java produced heavily optimized byte code. This turned out to be a mistake. With the advent of JIT compilation, the important methods are going to be compiled to very fast machined code. It’s therefore very important to make the job of the JIT compiler easier—as there are much bigger gains available from JIT compilation than there are from optimizing bytecode, which will still have to be interpreted. (查看原文)
    2016-10-07 17:44:52
    —— 引自章节:Introduction to the Java Envir
  • To check whether a float or double value is NaN, you must user the Float.isNaN() and Double.isNaN() methods. (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页
  • If the left operand is positive, 0s are shifted into the high-order bits. If the left operand is negative, 1s are shifted in instead. This technique is known as sign extension; it is used to preserve the sign of the left operand. (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页
  • If a finally block itself transfers control with a return, continue, break, or throw statement or by calling a method that throws an exception, the pending control transfer is abandoned, and this new transfer is processed. For example, if a finally clause throws an exception, that exception replaces any exception that was in the process of being thrown. If a finally clause issues a return statement, the method returns normally, even if an exception has been thrown and has not yet been handled. (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页
  • Java (since version 7) provides a very useful mechanism for automatically closing resources that require cleanup. This is known as try-with-resources, or TWR. (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页
  • This new form of try takes parameters that are all objects that require cleanup.2 These objects are scoped to this try block, and are then cleaned up automatically no matter how this block is exited. The developer does not need to write any catch or finally blocks—the Java compiler automatically inserts correct cleanup code. (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页
  • A lambda expression is essentially a function that does not have a name, and can be treated as a value in the language. As Java does not allow code to run around on its own outside of classes, in Java, this means that a lambda is an anonymous method that is defined on some class (that is possibly unknown to the developer). (查看原文)
    2016-10-07 18:08:58
    —— 引自第1页