java第十章

An aggregation relationship is usually represented as a data field in the aggregating class

A solid diamond is attached to the class of the composing class to denote the aggregation relationship with the composed object.

2 is the output of Integer.parseInt("10", 2)

To create an instance of BigDecimal for 454.45, use new BigDecimal("454.45");

To add BigInteger b1 to b2, you write b1=b2.add(b1);

In JDK 1.5, you may directly assign a primitive data type value to a wrapper object. This is called auto boxing.

在JDK 1.5中,可以直接将原始数据类型值赋给包装器对象。这叫做自动装箱。

Two strings with same contents aren't ALWAYS allocated to the same object.

Assume s is "ABCABC", the method s.replace('A', 'a') returns a new string "aBCaBC".

new String(a) is the correct statement to return a string from an array a of characters

ssume s is "ABCABC", the method s.toCharArray() returns an array of characters.

The replace method in the String class replaces a character in the string. But it doesn't change the content of the string.(It create a new string.)

 system.out.print("Hi, ABC, good".matches("ABC ") + " ");——>false

     system.out.println("Hi, ABC, good".matches(".*ABC.*"));——>true

You can append a string to a string buffer if the resulting new string exceeds the capacity.

To get a string from the StringBuffer, you use the toString method.

strBuf.charAt(strBuf.length() - 1) returns the last character in a StringBuilder variable named strBuf.

Assume StringBuilder strBuf is "ABCDEFG", after invoking strBuf.insert(3, "RRRR"), strBuf contains "ABCRRRRDEFG".

If your string does not require any changes, you should use String rather than StringBuffer to improve performance.

你可能感兴趣的:(java,蓝桥杯,职场和发展)