Java learning notes-vector, arraylist, array

Source: Internet
Author: User

I wrote a project in Java for the first time a while ago. It is less than two months since I carefully studied Java. Many times, I have to learn Java and write projects. But because of this, I deeply realized the simplicity and convenience of Java. Eclipse also plays a major role in this process.CodeIn Linux, I realized how cool it is to think about VI in Linux. All in all, I am deeply obsessed with Java, except that I cannot touch the memory.

The question is skipped.

 

Java beginners may encounter this problem when using Java:

What are the differences between array, arraylist, vector, list, and sort list in Java? In particular, what are the differences between vector, arraylist, and array? Because these three concepts are essentially the same, they are all arrays of data structures.

Here is an article about this question.Article:

Http://www.javaworld.com/javaworld/javaqa/2001-06/03-qa-0622-vector.html

I have already explained it clearly. Let me briefly summarize it.


The vector class is thread safe. That is to say, multi-thread calls to the same vector at the same time will not cause data confusion. The arraylist is NOT thread safe. ThereforeProgram, Use vector more, so you do not need to maintain concurrency yourself.


Data growth models are different. Both vector and arraylist are implemented using an array internally, which means that once the data volume exceeds the size of the original array, vector and arraylist both need to expand the array to meet the new data. The size of the new array is twice the size of the old array. Each time the arraylist is expanded, its array size is increased by only 50%.


Finally, if the program has high performance requirements, it is best to use the original array instead of vector and arraylist.


 

 

 

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.