Java object-oriented programming--The 12th JDK common class

Source: Internet
Author: User

1. System class

Java.lang Package System Class

SYS.OUT;SYS.EXIT;SYS.GC;

Sys.currenttimemillis ();----Gets the number of milliseconds from 1970-01-01 to the current time, long

Sys.getproperties (); &sys.getproperty () User.dir OK & get the working directory of current project, String type

2. Date class

Java.util Packet Date Class

@Deprecated--and the method is preceded by the note, which indicates that the method is obsolete and that new methods can be substituted.

3, Java.text Package SimpleDateFormat class return String type

Create date Format object, indicating the date formatting rules xx=new SimpleDateFormat ()

Xx.format (New Date ());

Outputs a Date object in the specified format

4. Java.lang String Class Equalsignorecase ();--> ignores case compared to

IndexOf ();--> returns the index of the first occurrence of the specified character in the string, if not found, returns 1

LastIndexOf ();--> returns the index of the last occurrence of the specified character in the string, if not found, returns 1

. Length ();--> Gets the length of the string

Replace (OLDCHAR,NEWCHAR)--Replaces all OldChar in the string with Newchar.

SUBSTRING ( int beginIndex, int endIndex) ——> Returns a new string, starting with the subscript beginindex, to the Endindex cutoff, without the endindex character. It is a substring of this string.

trim()­——>Returns a copy of the string, ignoring leading and trailing blanks, and the middle whitespace is not removed

Spilt ()--cuts a string with the given regular expression as a baseline, returns an array of strings

Matches ()---detects whether a string matches a given regular expression and returns True,false.

5, StringBuffer

String represents an immutable string, StringBuffer and StringBuilder represent a variable-content string.

Append, stitching strings,

Delete (A, B) to remove the sequence of characters in the string that is labeled from the A to the C (not including B)

Reverse, reversing the string

ToString, converting a variable of type StringBuffer to a string type

StringBuffer is a thread-safe class, and StringBuilder is a thread-insecure class. StringBuilder efficiency is higher than stringbuffer.

6. Packing class

Java encapsulates eight basic data types into classes, called wrapper classes.

Wrapper classes are final types, and they cannot be created as subclasses.

A wrapper class is an immutable class, and once an object of a wrapper class is created, the underlying type of data it contains cannot be changed.

The wrapper class has a mechanism for "auto boxing/unpacking".

7. The System class represents the running platform of the current Java program, and the runtime class represents the runtime environment of the Java program.

8. The math class is a mathematical tool class, where all methods are static. The randomness class is the most powerful random number generator in Java.

9, Regular expression: is a set of strings in the common characteristics of each string, using a specific symbol to describe a method of the group string, regular expressions can be used to search, edit or manipulate text and data. In Java, the pattern class and the Matcher class are provided with regular expressions.

The regular expression validates only the format and cannot validate the logic.

[] indicates that any of the characters can appear,

{} The minimum and maximum number of times a rule character can appear before the curly brace is represented.

To represent or, to wrap up with ().

* Equivalent to {0,}, can not appear, can also appear multiple times

+ equivalent to {1,}, appears at least once, no upper limit

? Equivalent to {0,1}, can not appear, or can occur only once

. Represents any character

\d represents 0-9 arbitrary numbers

\d represents non-numeric

\w denotes any number, letter, underline

\s represents a space or carriage return

\U4E00-\U9FA5: denotes the range of Chinese characters

Java object-oriented programming--The 12th JDK common class

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.