Re-stepping Learning Java _DAY14 (regular expression, Math,random,system,biginteger,bigdecimal,date,calendar)

Source: Internet
Author: User
Tags character classes dateformat square root

1: Regular Expressions (understanding)
(1) A string that conforms to a certain rule
(2) Common rules
A: Character
x character X. Example: ' A ' denotes character a
\ \ backslash character.
\ n New Line (newline) character (' \u000a ')
\ r return character (' \u000d ')

B: Character class
[ABC] A, B or C (simple Class)
[^ABC] Any character except A, B, or C (negation)
[A-za-z] A to Z or A to Z, the letters at both ends are included (range)
[0-9] 0 to 9 characters are included

C: Predefined character classes
. Any character. And mine is. The character itself, how to express it? \.
\d number: [0-9]
\w Word character: [a-za-z_0-9]
Things that make up words in regular expressions must have these things.

D: Boundary Matching device
^ The beginning of the line
End of the $ line
\b Word boundaries
is the place where the word character is not.
Example: Hello World?haha;xixi

E:greedy number of words
X? X, not once or once
X* X, 0 or more times
x+ X, one or more times
X{n} X, exactly n times
X{n,} X, at least n times
X{n,m} X, at least n times, but no more than m times
(3) Common function: (who is it used separately?)
A: Judging function
Public boolean matches of the String class (string regex)
B: Split function
Public string[of the String class] split (string regex)
C: Replace function
public string ReplaceAll of the String class (String regex,string replacement)
D: Get Features
Pattern and Matcher
Pattern p = pattern.compile ("A*b");
Matcher m = P.matcher ("Aaaaab");

Find (): Lookup does not exist
Group (): Get the data you just looked up
(4) Case
A: Determine phone number and mailbox
B: Split data according to different rules
C: Replace the number in the forum with *
D: Get a 3-character word in a string

2:math (Master)
(1) classes that operate on mathematical operations
(2) Common methods (self-completion)
A: Absolute Value
B: Rounding up
C: Rounding Down
D: Large values in two data
Power of E:a B
F: Random number
G: Rounding
H: Positive square root
(3) Case:
A: Guess the number games
B: Get random numbers of any range

3:random (understanding)
(1) A class for generating random numbers
(2) Construction method:
A:random () default seed, different random number generated each time
B:random (long Seed) specifies the seed, and the random number is the same each time the seed is the same
(3) member method:
A:int Nextint () returns the random number in the INT range
B:int nextint (int n) returns the random number in the range of [0,n]

4:system (Master)
(1) System classes, which provide some useful fields and methods
(2) member method (self-completion)
A: Run the garbage collector
B: Exit the JVM
C: Gets the millisecond value of the current time
D: Array Replication

5:biginteger (understanding)
(1) Operations on large integers
(2) Construction method
A:biginteger (String s)
(3) member method (self-completion)
A: Plus
B: Minus
C: Multiply
D: Except
E: Quotient and remainder

6:bigdecimal (understanding)
(1) floating point data to do operations, will lose precision. Therefore, it is recommended to use BigDecimal for floating-point data operations. (Financial-related projects)
(2) Construction method
A:bigdecimal (String s)
(3) member method:
A: Plus
B: Minus
C: Multiply
D: Except
E: Keep a few decimals yourself

7:date/dateformat (Master)
(1) Date is a class of dates that can be accurate to milliseconds.
A: Construction method
Date ()
Date (long time)
B: Member Method
GetTime ()
SetTime (long time)
C: Conversion of date and millisecond values to each other
Case: How many days have you been in this world?
(2) DateFormat classes that are formatted for dates and parsed for strings, but are abstract classes, use their subclasses SimpleDateFormat
A:simpledateformat (String pattern) given pattern
YYYY-MM-DD HH:mm:ss
B: Conversion of dates and strings
A:date--String
Format ()

B:string--Date
Parse ()
C: Case:
A tool class for date manipulation was created.

8:calendar (Master)
(1) The Calendar class, which encapsulates all the Calendar field values, can be obtained using a uniform method based on the incoming different calendar fields.
(2) How do I get a calendar object?
Calendar RightNow = Calendar.getinstance ();
Essentially, the subclass object is returned.
(3) member method
A: Get the corresponding value according to the Calendar field
B: Determine whether to add or subtract the value of the corresponding Calendar field based on the Calendar field and a positive negative number
C: Set Calendar object's Month day
(4) Case:
Calculate how many days in February of any year?

Re-stepping Learning Java _DAY14 (regular expression, Math,random,system,biginteger,bigdecimal,date,calendar)

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.