Home  >  Article  >  Java  >  What is the relationship between java arrays and containers

What is the relationship between java arrays and containers

WBOY
WBOYforward
2023-05-14 10:13:13916browse

1. Concept

Array is an efficient way to store and randomly access object reference sequences, but when an array object is created (note the difference from object array), The size of the array is fixed. When the array space is insufficient, a new array is created and all references in the old array are copied to the new array. (An array is a memory structure, and a container is a data structure) [If you know the length of the array and it will not increase in the future, then you must use the array; if the length of the array is variable or the length will increase, in order Use containers for convenience]

Container classes can only save references to objects. Arrays can be created to store primitive types directly or to store references to objects. You can use wrapper classes in containers, such as Integer, Double, etc., to save basic data type values.

2. The difference between arrays and containers

In Java, since there are powerful containers, is there no need for arrays? The answer is no.

It is true that in most cases, containers should be chosen to store data.

However, arrays are not without merit:

In Java, arrays are the most efficient way to store and randomly access a sequence of object references. Arrays are more efficient than containers (such as ArrayList).

Arrays can hold value types, but containers cannot (in this case, a wrapper class must be used).

What are the commonly used java frameworks

1. SpringMVC, Spring Web MVC is a lightweight Web framework based on Java that implements the request-driven type of Web MVC design pattern.

2.Shiro, Apache Shiro is a security framework for Java.

3.Mybatis, MyBatis is an excellent persistence layer framework that supports ordinary SQL queries, stored procedures and advanced mapping.

4.Dubbo, Dubbo is a distributed service framework.

5.Maven, Maven is a project management and build automation tool.

6.RabbitMQ, RabbitMQ is a high-concurrency and high-reliability AMQP message queue server implemented in Erlang.

7.Ehcache, EhCache is a pure Java in-process caching framework.

The above is the detailed content of What is the relationship between java arrays and containers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete