Blackhorse programmer _ Java API notes

Source: Internet
Author: User
 

 

----------- Android training, Java training, and Java learning technology blog. We look forward to communicating with you! ------------

API: What is an API? An API is an application programming interface. Simply put, it gives you a large library. You can implement all the libraries that are generally used for development, you only need to call it to complete the process. The best way to learn APIS is to first watch some videos and teach you how to use them. Then, you will have some knowledge about frequently used APIs, even if you do not remember them in the future, you only need to check the document.

Common classes: string and stringbuffer. The former is not extensible, and the latter is extensible. For example:

String STR = "ABCD ";

String STR = STR + "efgh ";

Although STR is changed, it is not extended, but a new string instance object is created internally to reference a new string, which is inefficient. Stringbuffer is scalable because it does not need to create a new instance object. After jdk1.5, a new stringbuilder class was added. stringbuilder is slightly more efficient than the stringbuffer class. However, in multi-threaded applications, stringbuffer should be used because stringbuiledr is NOT thread-safe.

Set: hashtable and properties. These two sets are a little old. Currently, the collection interface or map interface class is mostly used. For example, arraylist, hashmap, and hashmap.

Their methods are also slightly different. Generally, there is an add or put method to add objects, and a remove method to remove objects in the set. To traverse a set, an iterator object is returned to implement traversal,

The code implementation is generally:

Collection c = new collections (); object OBJ = new object (); C. add (OBJ); // Add an object iteratorc it = it. erator (); // get the iterator of the current object while (it. hasnext () {object OBJ = it. next ();}

 

After 1.5, most sets can be directly used for loop.

Date: date, calendar, which is generally used for format processing. There is a format in the calendar, which can convert the desired time output format into a character escape.

Math class: the most commonly used method is random (), which returns a random number ranging from 0 to 1, but is now almost replaced by the rondom class. Because the rondom class is better used. It can control the range of random output numbers.

 

----------------------- Android training, Java training, Java learning technology blog, hope to communicate with you! ----------------------

For details, see:Http://edu.csdn.net/heima

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.