Errors in java (1): errors in java
Because the first parameter of the replaceAll method is a regular expression, and "." represents any character in a regular expression, all the characters in the preceding string are replaced "/". If you want to replace only ".", it will take a long time to write it "\\.".
AWT: It is implemented by calling the native method of the operating system. Therefore, the AWT window on the Windows system is in the Windows style, while on the Unix system it is in the XWindow style. The graphic functions in AWT have a one-to-one relationship with the graphic functions provided by the operating system. We call them peers. That is to say, when we use AWT to construct a graphical user interface, we actually use the graphic library provided by the operating system. Because the graphic libraries of different operating systems provide different functions, functions on one platform may not exist on another platform. To implement the concept of "one-time compilation and running everywhere" declared by the Java language, AWT has to sacrifice its functions to achieve platform independence. That is to say, the graphic functions provided by AWT are the intersection of the graphic functions provided by various general operating systems. Since AWT relies on local methods to implement its functions, we usually call the AWT control a heavyweight control. Swing: the Lightweight component is not implemented through the native method, so the Swing window style is more diversified. However, Swing also has the heaveyweight component. For example, JWindow, Dialog, and JFrameSwing are called Lightweight components, which are not implemented through the native method. Therefore, Swing's window styles are more diversified. However, Swing also has the heaveyweight component. For example, JWindow, Dialog, and JFrameSwing are written in pure Java and have good portability and the same appearance on different platforms. Therefore, Swing components are called lightweight components (Swing is written by pure java code, so SWING solves the problem that JAVA cannot cross-platform because of window classes, the window function is also cross-platform and extensible, and SWING does not need to occupy too many system resources. Therefore, it is called a lightweight component !!!)
When Integer i01 = 59, the valueOf method of Integer is called,
public
static
Integer valueOf(
int
i) {
assert
IntegerCache.high>=
127
;
if
(i >= IntegerCache.low&& i <= IntegerCache.high)
return
IntegerCache.cache[i+ (-IntegerCache.low)];
return
new
Integer(i); }
This method is to return an Integer object. Before the return, it is considered as a judgment to determine whether the current I value is different from [-128,127] and whether this object exists in IntegerCache, if yes, a reference is directly returned. Otherwise, a new object is created.
Here, a new object is directly created because the program runs for the first time without 59.
Int i02 = 59, which is a basic type and stored in the stack.
Integer i03 = Integer.ValueOf(59); because this object already exists in IntegerCache, a reference is directly returned.
Integer i04 =NewInteger (59); create a new object directly.
System.Out. Println (i01 = i02); i01 is an Integer object, and i02 is an int object. Here we compare it with a value instead of an address. Integer is automatically split into int and then compared. So, true.
System.Out. Println (i01 = i03); Because i03 returns an i01 reference, it is true.
System.Out. Println (i03 = i04); Because i04 is a re-created object, i03 and i04 point to different objects, so the comparison result is false.
System.Out. Println (i02 = i04); Because i02 is a basic type, i04 will automatically split the box and compare the values. Therefore, the result is true.
Public Method [] getMethods () returns all public (public) methods of a class, including the public methods of its inherited class, and of course the methods of its Implemented interfaces.
Public Method [] getDeclaredMethods () indicates all methods declared by classes or interfaces, including public, protected, default (Package) Access, and private methods, but not inherited methods. Of course, it also includes the methods of the interfaces It implements.