Java programming things 43-array Overview

Source: Internet
Author: User

Java programming those things 43-array overview Zhengzhou game college Chen yuefeng from: http://blog.csdn.net/mailbomb Chapter 6 Array Array is a basic data storage structure built in the Java language. It is a set of numbers to store multiple data at a time. Array is Program Many implementations Algorithm Can be simplified to a certain extent. Code . Java Arrays in languages can be divided into one-dimensional arrays and multi-dimensional arrays. This section describes the concept and related understanding and use of multi-dimensional arrays based on one-dimensional arrays. 6.1 array Overview In a program, if you need to store a value, you can declare a variable in the Code for storage. However, in some cases, for the convenience of program operations, you need to store a group of related values, which is the initial cause of the array. In actual use, an array is used to store a set of related data, such as a card or card in a card game. From the perspective of data storage, its function is equivalent to variable. In actual use, the array name is a whole, similar to the class name in the school. To facilitate access to a specific value in the array, the value in the array is forcibly numbered, this number is called the subscript of an array, similar to the serial number of each student in the class. When actually referencing values in an array, use the array name and subscript to specify them together, similar to a student whose XX class number is N. For the convenience of array management, each element type in the array must be the same in syntax. Each specific value in the array is also called an array element. In the memory, the array is stored in the continuous area. Because each element in the array has the same type, the occupied memory size is the same, therefore, when accessing elements in an array, you can directly calculate the element position based on the starting position and subscript of the array in the memory. Therefore, the access speed of the array is very high. In actual use, each array has a length. To facilitate management, the length of the array must be specified during array initialization in Java. Once specified, the length cannot be changed, unless the array is reinitialized. After learning about the concepts related to arrays, the programmer specifies the array type, length, and functions of each element in the array when using arrays, these require some design skills, which is also the least familiar to beginners. This problem can be simply understood in this way, just as if you have a piece of mud, as long as you follow the rules, you can make any structure according to your needs, both the production process and method are designed by the producer. Although the array structure only stores multiple variables in the previous syntax together and uses the array name combination of the upper and lower mark. This is a simple change, it will greatly simplify the implementation of program algorithms, so array is a great innovation in data storage. Or use a buzzword-"a small step in data storage, indeed a huge step in Algorithm Implementation ". Another change to the array is that the subscript can be represented by variables, which makes it more flexible to access the array value. This is also the key to understanding the array. To sum up, there are mainly the following points: 1, The element types in the array must be the same. 2, The length of the array cannot be changed once specified. 3, The values in the array are accessed by combining the array name and subscript.
Related Article

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.