The eighth chapter: Java Common Class (i)

Source: Internet
Author: User

    1. Java.long Bag

      The classes and interfaces commonly used in Java development are placed under the Java.lang package, so to simplify the use of classes under this package, classes under the Java.lang package do not need to be imported when they are used.

    2. The parent class for all classes of the Java.lang.Object class. All classes (including arrays) inherit directly or indirectly from the object class, and also inherit the methods in the class. That is, any class can call a method in the Java.lang.Object class directly . 650) this.width=650; "src=" Http://img.baidu.com/hi/face/i_f13.gif "alt=" I_f13.gif "/>

    3. The object class has only one argument-less constructor.

      Object ();

    4. Methods commonly used in object (see the Java API for specific use):


1.equals () compares two objects for the same.

The return value is a boolean type.

The specific notation is boolean x=a.equals (b);

Note: equals can only compare objects, not the base data type (values of variables/constants, etc.).

2. hashcode () returns the hash code of an object (the hash code is a number that is automatically given to the object when the object is run, unique, tested, and only related to the order in which the object is run in the program, with no relation to the object itself.) )

The return value is of type int

3.toString () converts an object to a string

The return value is of type String.

The converted string is related to the hash code of the object.

The 5.String class represents a string that provides methods for string processing that are commonly used in development, such as: the length of the string, the interception of strings, the substitution of strings, and so on.

A string object is a constant, and its value cannot be modified after it is created.

Common construction methods for String classes

String () non- parametric construction method

String (String str) has a method for constructing a string argument

String (char[]ch) has a method for constructing an array parameter of type Char

String (byte[] b) has a method for constructing a byte array parameter

String declaration and how to create a string object:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/1E/wKiom1X1ieeSMgOAAAIyqEPHAGY962.jpg "title=" Stringcj.jpg "alt=" Wkiom1x1ieesmgoaaaiyqephagy962.jpg "/>

The eighth chapter: Java Common Class (i)

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.