Java is just a collection

Source: Internet
Author: User

1. Main differences between array and arraylist:
1) you can think of arraylist as an "array that automatically expands the capacity ".

2) array ([]): it is the most efficient, but its capacity is fixed and cannot be changed dynamically;
Arraylist: The capacity can be dynamically increased, but the efficiency is sacrificed;

3) Based on the efficiency and type test, array should be used as much as possible. arraylist is used only when the array size cannot be determined!


2. Convert object [] array. toarray () to string []

The array is also of the object type and cannot be converted forcibly.

String [] array = new string [O. Length];
For (INT I = 0; I <O. length; I ++)
{
Array [I] = O [I]. tostring ();
}


3. Synchronized Method:
The Declaration is to define the scope and scope of the variable.
The synchronized method is declared by adding the synchronized keyword to the method declaration. For example:
Public synchronized void accessval (INT newval );

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.