Java basic grammar - Regular Expressions

Regular Expressions

  1. Regular expressions (expressions correct rule) is used to describe or refer to a single matching character string matches a series string of syntactic rules. It is actually a rule. It has its own special applications.

  2. Regular expressions to determine the function: public boolean matches (String regex)

  3. Regular expressions split function: public String [] split (String regex)

  4. Replace regular expression functions: public String replaceAll (String regex, String replacement)

  5. Regular expressions acquisition function: Using the Pattern and Matcher

  6. Pattern Matcher and Overview:
    pattern object is a regular expression compiler representation. Pattern no public class constructor. To create a Pattern object, you must first call its public static compile method that returns a Pattern object. The method accepts a regular expression as its first parameter.
    Matcher object is input string matching operation will be explained and the engine. Like the Pattern class, Matcher no public constructor. You need to call the matcher method Pattern object to obtain a Matcher object.

  7. Math class Overview and methods:
    a method to perform basic mathematical operations A.Math class contains, ever other exponential, logarithmic, trigonometric functions and square root.
    B. member variable
    public static final double E: NATURAL base-
    public static final double PI: pi
    C. members method
    public static int abs (int a) the absolute value
    public static double ceil (double a) rounded up
    public static double floor ( double a) rounded down
    public static int max (int a, int b) obtaining a maximum value
    public static int min (int a, int b) obtaining the minimum value
    public static double pow (double a, double b) obtaining a, b power
    public static double random () returns a random number acquisition double value with a positive sign, which is greater than or equal to 0.0 and less than 1.0.
    public static int round (float a) rounding
    public static double sqrt (double a) obtaining a positive square root

  8. Overview and methods of using the Random class
    A: Overview Random class
    type for generating a random number if the Random creates two instances with the same seed,
    the same for each instance sequence of method calls, which will generate and return the same sequence of numbers.
    B: Constructors
    public Random () is not given seed, using the default (current milliseconds System)
    public the Random (long SEED) Given a long type seeds, each time after a given random number generated by the same the
    C: method members
    public int nextInt () // no random number range parameter represents the range of type int
    public int nextInt (int n) // can specify a range of random numbers
    void nextBytes (byte [] bytes) generates a random word section and placed in an empty byte array provided by the user.

  9. SUMMARY System and method for using class
    A: System Overview class
    System class contains several useful class fields and methods. It can not be instantiated.
    B: member method
    public static void gc () // call the garbage collector
    public static void exit (int status) // quit java virtual machine 0 0 non-normal exit as a leave
    public static long currentTimeMillis () // Get the current time millisecond value

  10. BigDecimal class overview and method
    A: BigDecimal overview
    due at the time of operation, float type and double precision can easily be lost, presentation cases.
    Therefore, in order to accurately represent, floating point calculation, Java provides BigDecimal
    immutable, arbitrary-precision signed decimal numbers.
    B: constructor
    public the BigDecimal (String Val)
    C: Method members
    public BigDecimal add (BigDecimal augend) // add
    public BigDecimal subtract (BigDecimal subtrahend) // Save
    public BigDecimal multiply (BigDecimal multiplicand) // by
    public BigDecimal divide (BigDecimal divisor ) // division
    public BigDecimal divide (BigDecimal divisor, int scale, int roundingMode) // scale behind the decimal point several
    // mode, such as the roundingMode rounding offs

  11. Overview and using methods of the Date class
    A: Date Class Overview
    class Date represents a specific moment, with millisecond precision.
    B: Constructors
    public a Date ()
    public a Date (long DATE) // converts a type of milliseconds long as a date object
    C. members method
    public long getTime (): Get a date subject object milliseconds
    public void setTime (long time): Example milliseconds object is set to a specified date: date.setTime (1000 * 60 * 60);
    D.Date ---- Long conversion
    call method getTime

    long - Date of conversion
    can be constructed using methods
    setTime (long time)

  12. SimpleDateFormat class implements and the date string conversion
    A.SimpleDateFormat: a date object can be formatted as a text (character string), a date may be the date string object is parsed into a
    B. constructor:
    public SimpleDateFormat (): to create a SimpleDateFormat object using the default mode of
    public SimpleDateFormat (String pattern): using the specified mode (such as rules yyyy: mM: dd HH: mm : ss)
    to create a SimpleDateFormat objects
    C. rule definition
    y- month in M- d- m- days points seconds H- s-
    D. member methods:
    public string the format (a date dATE): a date format to a string object to a
    public date parse (string dateStr): the parsing a string to a date Note to resolve target date in the specified format

  13. Overview Calendar class and method to get the date of
    A: Overview Calendar Class
    Calendar class is an abstract class that can not be directly new object, you can come get his target through his a static member method getInstance ()
    which is a particular moment with a group such as YEAR, MONTH, DAY_OF_MONTH, HOUR
    conversion between calendar field provides methods like, and for manipulating the calendar fields (e.g., date of obtaining the next week) provides a number of methods.
    B: Method member
    when public static Calendar getInstance () using the default locale area and a calendar object obtained
    public int get (int field) to obtain a given calendar field value corresponding to the field provided by the field to come and collect Calendar

  14. Add Calendar category () and set () Method
    A: Method members
    public void add (int field, int amount) in accordance with the rules of the calendar, adding a field for a given calendar minus the specified amount of time or
    public final void set (int year, int month, int date) set the calendar date time

  15. Supplementary BigInteger overview allows data to be within a range of more than Integer calculates
    A. constructor
    public BigInteger (String Val)
    B. member methods
    public BigInteger the Add (BigInteger Val)
    public BigInteger Subtract (BigInteger Val)
    public BigInteger Multiply (BigInteger Val)
    public BigInteger Divide (a BigInteger Val)
    public a BigInteger [] divideAndRemainder (a BigInteger Val)
    the I'm Loyal to the except Nothing The Dream.
    ---- Captain America

Published 39 original articles · won praise 1 · views 570

Guess you like

Origin blog.csdn.net/love_to_share/article/details/102905751