20165211 2017-2018-2 "Java Programming" 6th Week study Summary

Source: Internet
Author: User
Tags time and date

20165211 2017-2018-2 "Java Program Design" 6th Week Study summary Textbook study summary

This week, I learned the contents of Chapter 85 or 15 of the book, the following is my main knowledge.

The eighth chapter constructs the string object by the common practical class string class

Constant objects:,,, "你好" "12.97" "boy" string constants are also objects, so they also have their own references and objects.

String object:

    1. "'" String s = new String ("We are students");
    2. char a[]={‘J‘,‘a‘,‘v‘,‘a‘}; String s=new String(a)
    3. Extracts a portion of a character array:char a[] ={‘0‘,‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘}; String s=new String(a,2,4);

Reference string constants:String s1,s2; s1="你好"; s2="你好";

The string is collocated

Use "+" for collocated operations

Common methods of the string class
format function
public int Length () To find the string length
public boolean equals (String s) Compares character sequences of two strings
public Boolean StartsWith (string s), public boolean endsWith (string s) Determines whether the prefix of a two-character sequence is the same
public int CompareTo (String s) Size comparison by dictionary order
Public Boolean contains (String s) Determines whether the parameter S is included in the string
public int indexOf (string s), public int lastIndexOf (string s) Finds characters or substrings in the current string, returns the position
Public String substring (int startpoint) Copy the characters from the StartPoint position to the last position
Public String trim () Remove the front and back spaces of the word character
Conversion of strings to basic data types

1) Public String valueOf (byte b)
2) public static String valueOf (int i)
3) public static String valueOf (long L)
4) public static String valueOf (float f)
5) public static String valueOf (double D)

The representation of a string in an object

public String toString()Method

strings and character arrays, byte arrays

string and character array: getChar() method copies a portion of the character sequence of the current string object into the array specified in Parameter C. Another: public char[] toCharArray() .

String and byte arrays: The construction method of the string class String(byte[]) constructs a string object with the specified byte array. String(byte[],int offset,int length)constructs a string object by taking a length byte from the offset position of the specified byte array.

Encryption of strings

Regular expressions and the substitution and decomposition of strings

Regular expression: A string character that has a special meaning. You can use the qualifier modifier in a regular expression.

Substitution of strings:public String replaceAll(String regex,String replacement)

Decomposition of character sequences:public String[] split(String regex)

StringTokenizer class

Breaks down the character sequence of a string object without using a regular expression to make a delimited mark.

StringTokenizer (String s,string Delim): Constructs a parser that uses any arrangement of characters in the Delim character sequence as a split mark, without using the default split mark.

Scanner class

Scanner objects: You can parse words in a sequence of characters.

The difference between StringTokenizer and scanner: StringTokenizer stores all the broken words into the entity of the StringTokenizer object, and the scanner class simply stores the delimited tags that get the words.

StringBuffer Class StringBuffer Object

The memory space of an entity of an object of the StringBuffer class can automatically change size

Common methods of the StringBuffer class (common methods of the StringBuffer class)

Append method Xpublic char charAt (int n), public void Setcharat (int n,char ch)

StringBuffer Insert (int index,string str)

Public StringBuffer Reserve ()

StringBuffer Delete (int startindex,int endIndex)

StringBuffer replace (int startindex,int endindex,string str);

Date class and Calendar class Date class

Use the parameterless construction method to get the current date and time of the machine

Use the constructor with parameters to set the time and date independently.

Calendar class

Initialize a Calendar object

Formatting the date Format method

Format mode

Date nowtime = new Date();String s1 = String.format("%tY年%tm月%td日",nowtime,nowtime,nowtime);String s2 = String.format("%tY",nowtime);

Date list: A comma-delimited calendar object or Date Object

Format the same date: use "<" in format mode

Week format for different regions

Overloaded square I method using format

Math class, BigInteger class, Random class

Math class: Usage of the Java Math tool class

BigInteger class: JAVA BigInteger class methods use

Random class: An explanation of the use of the random class in Java

Number formatting class and console class and class 15th generic generic class declaration with set-up framework generics and Matcher classes

"Class name < generic list >", for example:class people<e>

Generic class bodies are exactly like ordinary class bodies, with member variables and method compositions

Declaring an object using a generic class

Using a generic class to declare an object, the class name is more <> than the normal class, and generics in <> must be replaced with a specific type.

Linked list

LinkedList

Common methods: Application of LinkedList method in Java

Traversing a linked list

Sorting and finding

Shuffle and rotate

Stack hash map tree Set tree Map Auto Boxing and unboxing code hosting

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 37/37 1/1 10/10
Second week 399/436 1/2 12/22
Third week 764/1163 1/3 18/40
Week Four 687/1813 1/4 12/52
Week Five 1127/2916 1/5 10/62
Week Six 1175/4160 2/7 14/76

20165211 2017-2018-2 "Java Programming" 6th Week study Summary

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.