Home  >  Article  >  Java  >  How to use java array

How to use java array

coldplay.xixi
coldplay.xixiOriginal
2020-08-18 11:35:123542browse

How to use Java arrays: First declare the array before use and tell the computer what the data type is; then allocate space and tell the computer to allocate several consecutive spaces; finally assign a value to the array.

How to use java array

[Related learning recommendations: java basic tutorial]

How to use java arrays:

1. We have learned the definition and meaning of arrays in Java, but how to use them? When we experiment with arrays, we use the keyword NEW to instantiate the array before it can be used. We will introduce it in detail starting from the fifth step.

How to use java array

#2. Declare the array before use. Declaring an array tells the computer what the data type is. The specific implementation steps are as follows

How to use java array

#3. Then allocate space. Allocating space is to tell the computer to allocate several consecutive spaces.

How to use java array

#4. Finally assign a value to the array. Assigning a value to an array means putting data into the allocated grid.

How to use java array

#5. How to assign a value to an array. Above we introduced assigning values ​​to arrays, but how to assign values ​​specifically? There are generally two situations, which are also the most commonly used situations. Remember not to make the size of the array exceed the length.

How to use java array

Related learning recommendations: Programming video

The above is the detailed content of How to use java array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn