Easy error in Java (i)

Source: Internet
Author: User

Because the first argument of the ReplaceAll method is a regular expression, the "." Any character is represented in a regular expression, so all characters of the preceding string are nonalphanumeric replaced by "/". If you want to replace only ".", so long to write "\ \".

Awt: is implemented by invoking the native method of the operating system, so the AWT window on the Windows system is the style of windows, while on UNIX systems it is Xwindow style. The graphical functions in AWT have a one by one correspondence with the graphical functions provided by the operating system, which we call Peers. In other words, when we use AWT to build a graphical user interface, we are actually using the graphics library provided by the operating System. Features that exist on one platform may not exist on another because of the different functionality that is provided by the graphics library of the operating System. In order to implement the concept of "once compiled, run everywhere" in the Java language, AWT has to implement its platform independence by sacrificing functionality, that is to say, the graphical capabilities provided by AWT are the intersection of the graphical functions provided by various general-purpose operating Systems. Since AWT relies on local methods to implement its functionality, we often refer to AWT controls as heavyweight controls. Swing: the so-called lightweight component is not implemented by the native method, so Swing's window style is more diverse. however, Swing also has heaveyweight Components. For example, Jwindow,dialog,jframeswing is the so-called lightweight component, not implemented by native method, so Swing's window style is more diverse. however, Swing also has heaveyweight Components. For example, jwindow,dialog,jframeswing is written in pure java, portability is good, the appearance of the same on different platforms. So swing parts are called lightweight components (swing is written by pure Java code, so swing solves the problem that Java does not cross the platform because of the window class, so that the window function also has cross-platform and extensibility features, and swing does not need to occupy too much system resources. So called lightweight components!!! ) Integer i01=59 的时候,会调用 Integer 的 valueOf 方法,  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); }

The method is to return an Integer object, just before returning, as a judgment, to determine whether the current value of I is different in [-128,127], and whether the object exists in integercache, or if so, to return the reference directly, otherwise, create a new Object.

In this case, since the program first runs, there is no 59, so a new object is created Directly.

int i02=59, which is a basic type, is stored in the STACK.

Integer i03 =integer. valueOf (59); Because this object already exists in integercache, the reference is returned DIRECTLY.

Integer i04 = new integer (59); Create a new object directly.

System. Out. println (i01== i02); I01 is an Integer object, and i02 is an int, where the comparison is not an address, but a Value. The Integer is automatically disassembled into int, and then the value is Compared. so, to be True.

System.  Out. println (i01== i03); Because i03 returns a reference to the i01, it is True.

System.  Out. println (i03==i04); Because I04 is a re-created object, i03,i04 is pointing to a different object, so the comparison result is False.

System.  Out. println (i02== i04); Because I02 is a basic type, the i04 is automatically disassembled at this point, and the value is compared, so the result is True.

public method[] getmethods () Returns all public methods of a class, including the common methods of its inheriting classes, and, of course, The methods of the interfaces it Implements.
public method[] the Getdeclaredmethods () object represents all of the methods declared by the class or interface, including common, protected, default (package) access, and private methods, but does not include inherited METHODS. Of course, It also includes the method of the interface it Implements.

Easy error in Java (i)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.