Java BASICS (11) Summary of common classes (1) and java Basics

Source: Internet
Author: User

Java BASICS (11) Summary of common classes (1) and java Basics

Here are some of the knowledge points and code I summarized in my previous class. Most of the notes I think are very good and classic, sincerely hope that these will help those who want to learn!

It is inconvenient to upload code by module. There are also many things, and they are also clear! If you need it, you can leave your email in the comments. I will certainly send it to you for free! Thank you for making progress on this platform !! Remember that programmers are selfless !!!

Also very welcome to my blog to watch blog address: http://www.cnblogs.com/duscl/

 

/* 2: API Overview (understanding) (1) application programming interface. (2) It is the java class that JDK provides to us to improve programming efficiency. 3: Object Class (master) (1) Object is the root class of the class hierarchy. All classes are directly or indirectly inherited from the Object class. (2) There is a constructor for the Object class, and there is no parameter construction. This is to understand what we said at the time. By default, the sub-class constructor accesses the structure of the parent class without parameters (3) methods to be mastered: A: toString () returns the string representation of the object, which is represented by the class full path + '@' + hexadecimal hash value by default. This representation is meaningless. Generally, this method is overwritten by subclasses. How to rewrite it? I also explained the process. Basically, the information is required to be simple and clear. But it is still automatically generated. B: equals () is used to compare whether two objects are the same. By default, compare whether the address values are the same. The comparison of the address value is meaningless. Therefore, this method is also overwritten by the subclass. I also explained and analyzed the rewrite process in detail. But it is still automatically generated. (4) method to understand: A: hashCode () returns the hash value of the object. It is not an actual address value. It can be understood as an address value. B: getClass () returns the object's bytecode file object. In reflection, we will explain in detail C: finalize () is used for garbage collection. At an uncertain time, D: clone () object cloning can be implemented, including data replication of member variables, but it is different from two references pointing to the same object. (5) two considerations. A: directly output an object name. In fact, the toString () method of the object is called by default. B: What is the difference between question = and equals? A: = Basic Type: compare whether the value is the same reference type: compare whether the address value is the same B: equals () can only compare the reference type. By default, compare whether the address values are the same. However, we can rewrite this method as needed. 1: usage (understanding) (1) categories used for keyboard data entry after jdk5. (2) constructor: A: Explains System. in. It is actually a standard input stream, corresponding to keyboard input B: constructor InputStream is = System. in; second (InputStream is) C: the common format is second SC = new second (System. in); (3) Basic Method format: A: hasNextXxx () determines whether it is A certain type of B: nextXxx () returns A certain type of elements (4) two methods to be mastered: public int nextInt () B: public String nextLine () (5) minor issues to be aware of. A: For the same sequence object, first obtain the value and then obtain the String. B: solution: a: redefine a struct object B: get all the data using strings, and then convert the data accordingly. 2: Overview and use of the String class (master) (1) A string of multiple characters. In fact, it can be converted to a character array. (2) constructor: A: public String () B: public String (byte [] bytes) C: public String (byte [] bytes, int offset, int length) D: public String (char [] value) E: public String (char [] value, int offset, int count) F: public String (String original) the following is not A constructor, but the result is also A String object G: String s = "hello"; (3) character of the String A: Once A String is assigned A value, it cannot be changed. Note: The content of the string cannot be changed, rather than the reference cannot be changed. B: What is the difference between the literal value as a String object and the String s = new String ("hello") created through the constructor? (4) A: = and equals () String s1 = new String ("hello "); string s2 = new String ("hello"); System. out. println (s1 = s2); // false System. out. println (s1.equals (s2); // true String s3 = new String ("hello"); String s4 = "hello"; System. out. println (s3 = s4); // false System. out. println (s3.equals (s4); // true String s5 = "hello"; String s6 = "hello"; System. out. println (s5 = s6); // true System. out. println (s5.equals (s6); // true B: String concatenation String s1 = "hello"; String s2 = "world"; String s3 = "helloworld"; System. out. println (s3 = s1 + s2); // false System. out. println (s3.equals (s1 + s2); // true System. out. println (s3 = "hello" + "world"); // false. This is an error. It should be true System. out. println (s3.equals ("hello" + "world"); // true (5) string function (Chinese meaning of the Self-complementing method) A: boolean equals (Object obj) boolean inclusignorecase (String str) boolean contains (String str) boolean startsWith (String str) boolean endsWith (String str) boolean isEmpty () B: Get function int length () char charAt (int index) int indexOf (int ch) int indexOf (String str) int indexOf (int ch, int fromIndex) int indexOf (String str, int fromIndex) string substring (int start) String substring (int start, int end) C: Conversion Function byte [] getBytes () char [] toCharArray () static String valueOf (char [] chs) static String valueOf (int I) String toLowerCase () String toUpperCase () String concat (String str) D: other functions a: replacement function String replace (char old, char new) string replace (String old, String new) B: Space Removal Function String trim () c: dictionary-based comparison function int compareTo (String str) int compareToIgnoreCase (String str) (6) string case A: Simulate User Login B: String traversal C: count the number of uppercase/lowercase and numeric characters in the string D: Convert the first letter of the string to uppercase, and other lowercase E: concatenate an int array into a string of the specified format. F: String inversion. G: count the number of occurrences of a small string *\

 

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.