Core Java Volume I - Fundamentals (10th) 1-8章 阅读笔记

来源:互联网 发布:c语言详解 编辑:程序博客网 时间:2024/05/21 07:34
001. reasure
[v] say or do something to remove the doubts and fears of someone.

002. website
    http://horstmann.com/corejava

003. deploy
[v] move (troops) into position for military action.

004. hype
[n] extravagant or intensive publicity or promotion.

005. Simply stated, object-oriented design is a programming technique that focuses on the data(= objects) and on the interfaces to that object.

006. The major difference between Java and C++ lies in multiple inheritance, which Java has replaced with the simpler concept of interfaces.

007. On Linux, add a line such as following to the end of your ~/.bashrc or ~/.bash_profile file:
    export PATH=jdk/bin:$PATH

008. jdk-version-docs-all.zip
    www.oracle.com/technetwork/java/javase/downloads

009. The constants Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, and Double.NaN represent these special values, but they are rarely used in practice.

010. Our strong recommentdation is not to use the char type in your programs unless you are actually manipulating UTF-16 code units. You are almost always better off treating strings as abstract data types.

011. A >>> operator fills the top bits with zero, unlike >> which extends the sign bit into the top bits.

012. An enumerated type has finite number of named values. For example:
    enum Size {SMALL, MEDIUM, LARGE, EXTRA_LARGE };

013. Since you cannot change the individual characters in a Java string, the documentation refers to the objects of the String class as immutable.

014. To test two strings are identical except for the upper/lowercase letter distinction, use the equalsIgnoreCase method.
    "Hello".equalsIgnoreCase("hello");

015. intermittent
[adj] occuring at irregular intervals.

016. Sometimes, you need to test that a string is neither null nor empty. Then use the condition
    if (str != null && str.length() != 0)

017. Java™ Platform, Standard Edition 8 API Specification
    https://docs.oracle.com/javase/8/docs/api/

018. The characters in the basic multilingual plane are represented as 16-bit values, called code units. The supplementary characters are encoded as consecutive pairs of code units.

019. StringBuilder appendCodePoint(int cp)
    appends a code point, converting it into one or two code units, and teturns this.

020. venerable
[adj] accorded a great deal of respect, esp. because of age, widsom, or character.

021. The index must immediately follow the %, and it must be terminated by a $. For example,
    System.out.printf("%1$s %2$tB %2$te, %2$tY", "Due date:", new Date());
    Due date: February 9, 2015

022. To read from a file, construct a Scanner object like this:
    Scanner in = new Scanner(Paths.get("myfile.txt", "UTF-8));

023. The continue statement transfers control to the header of the innermost enclosing loop.

024. The enhanced for loop
    for (varivable : collection) statement
sets the given variable to each element of the collection and then executes the statement.

025. culprit
[n] a person who is responsible for a crime or other misdeed.

026. Formally, encapsulation is simply combining data and behavior in one package and hiding the implementation details from the users of the object.

027. UML
Inheritance / Interface implementation / Dependency / Aggregation / Association / Directed association
(Table 4.1)

028. The standard Java library contains two separate classes: the Date class, which represents a point in time, and the LocalDate class, which expresses days in the familiar calendar notation.

029. dissect
[v] methodically cut up (a body, part, or plant) in order to study internal parts.

030. method parameter
A method cannot modify a parameter of a primitive type.
A method can change the state of an object parameter.
A method cannot make an object parameter refer to a new object.

031. The initialization block runs first, and then the body of the contructor is executed.

032. Java uses the keyword super to call a superclass method. In C++, you would use the name of the superclass with the :: operator instead.

033. Recall that the this keyword has two meanings: to denote a reference to the implicit parameter and to call another constructor of the same class. Likewise, the super keyword has two meanings: to invoke a superclass method and to invoke a superclass constructor.

034. smuggle
[v] move(goods) illegally into or out of a country.

035. You can cast only within an inheritance hierarchy.
Use instanceof to check before casting from a superclass to a subclass.

036. Abstract classes cannot be instantitated. That is, if a class is declared as abstract, no objects of that class can be created.

037. Here is a recipe for writing the perfect equals method:
1. Name the explicit parameter otherObject -- later, you will need to cast it to another variable that you should call other.
2. Test whether this happens to be identical to otherObject:
    if (this == otherObject) return true;
3. Test whether otherObject is null and return false if it is. This test is required.
    if (otherObject == null) return false;
4. Compare the classes of this and otherObject. If the semantics of equals can change in subclasses, use the getClass test:
    if (getClass() != otherObject.getClass()) return false;
If the same semantics holds for all subclasses, you can use an instanceof test:
    if (!(otherObject instanceof ClassName)) return false;
5. Cast otherObject to a variable of your class type:
    ClassName other = (ClassName) otherObject;
6. Use == for primitive type fields, Object.equals for object fields.
    return field1 == other.field1
        && Objects.equals(field2, other.field2)
        && ...;
If you redefine equals in a subclass, include a call to super.equals(other).

038. scramble
[v] make one's way quickly or awkwardly up a steep slope or over rough ground by using one's hands as well as one's feet.

039. The wrapper classes have obvious names: Integer, Long, Float, Double, Short, Byte, Character, and Boolean.

040. courtesy
[n] the showing of politeness in one's attitude and behavior toward others.

041. The printf method is defined like this:
    public class PrintStream
    {
        public PrintStream printf(String fmt, Object... args) { return format(fmt, args); }
    }

042. The three classes Field, Method, and Constructor in the java.lang.reflect package describe the fields, methods, and constructors of a class, respectively.

043. Constructor references are just like method references, except that the name of the method is new.

044. ingredient
[n] any of the foods or substances that are combined to make a particular dish.

045. squeamish
[adj] (of a person) easily made to feel sick, faint, or disgusted, esp.

046. An object that comes from an inner class has implicit reference to the outer class object that instantiated it.

047. A static inner class is exactly like any other inner class, except that an object of a static inner class does not have a reference to the outer class object that generated it.

048. Notice that all exceptions descend from Throwable, but the hierarchy immediately splits into two branches: Error and Exception.

049. The code in the finally clause executes whether or not an exception was caught.
InputStream in = new FileInputStream();
try { // code that might throw exceptions }
catch { // show error message }
finally { in.close(); }

050. StackTraceElement[] getStackTrace()
gets the trace of the call stack at the time this object was constructed.

051. suppress
[v] forcibly put an end to

052. A type variable or wildcard can have multiple bounds. For example:
    T extends Comparable & Serializable
The bounding types are separated by ampersands(&) because commas are used to separate type variables.

053. A minimal form of a queue interface might look like this:
public interface Queue<E>
{
    void add(E element);
    E remove();
    int size();
}
0 0
原创粉丝点击