In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what the multi-dimensional array in Java is, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
0, preface and mind map 0.1 how to understand multi-dimensional arrays?
A multi-dimensional array can be regarded as an array of an array. For example, a two-dimensional array is a special one-dimensional array, and each element is an one-dimensional array.
0.2 mind map:
1. Dynamic initialization of multidimensional array
★ takes two-dimensional array as an example
1.1 grammatical format
Allocate space directly for each dimension in the following format:
Type [] [] typeName = new type [row] [col]
Type can be basic data type and compound data type, row and col must be positive integers
Row is the number of rows and col is the number of columns.
1.2 to help with the solution by example
Such as defining a two-dimensional array:
Int a [] [] = new int [2] [5]
Explanation: a two-dimensional array can be thought of as an array of two rows and three columns.
2. References to multidimensional arrays
★ takes two-dimensional array as an example
2.1 citation mode
For each element in the two-dimensional array, the reference is arrayName [index1] [index2].
For example:
Num [1] [0]
In fact, two-dimensional or even multi-dimensional arrays are very easy to understand, so let's just take two or more values as positioning.
The original array is a line, and we just need to know the location of a point, because that point is on the line.
Two-dimensional is a face, and two points determine a position.
Three-dimensional, you need three points to determine.
...
and so on!
3. Add: get the array length
The length of the first dimension of the two-dimensional array obtained by a.length, a [0] .length is the length of the first array of the second dimension.
The above is all the content of the article "what is a multidimensional array in Java". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.