Record some of the APIs you encounter in work learning, tips

Source: Internet
Author: User

  Usually in the study encountered some very interesting code writing. Record down and raise the level. Of course because I am a novice, may have more strange suspicion.

Using the pattern class to match regular expression rules

int num = 1= "[0-9]+"; // fill in the required regular expression rules
Pattern pattern = Pattern.compile (REG); Boolean yn=pattern.matcher (string.valueof (num)). matches (); System.out.println (YN);

Comparer definition

comparator<integer> CP = (x, y) x > y? 1: (x < y? -1:0);

Swap (ARR,A,B) does not use temporary variable notation

/**@param@param @param*/Public  void swap (intintint  b) {    ^= arr[b];     ^= Arr[a];     ^= arr[b];}

String.Format

* 100)

You can output the data in a formatted format, and the results appear as follows:

Record some of the APIs you encounter in work learning, tips

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.