In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use big data array". The content in the article is simple and clear, and it is easy to learn and understand. now please follow the editor's train of thought to study and learn "how to use big data array".
1.5.1 Array definition and element access
An array is a container that stores a specified data type
Note:
1. An array is a container of fixed length. Once the instantiation is completed, the length cannot be modified.
The noun explains:
1. Array length: refers to the capacity of the container, indicating how much data can be stored in the array
two。 Element: refers to the data stored in the array
3. Subscript: an index of the position of an element in an array
4. Traversal array: get each element of the array in turn
* * element access to array * *
Accessed by subscript, the subscript of the elements in the array starts at 0
The subscript of the element in the array: [0, array .length-1]
* * Note: * *
When accessing the elements in the array, pay attention to the range of the subscript, do not cross the boundary!
Traverse the array:
1. Use looping through the subscript
```java
Int [] array = {1,2,3}
For (int index = 0; index < array.length; index++) {
System.out.println (Array index)
}
`
two。 Use enhanced for loops
```java
Int [] array = {1,2,3}
For (int ele: array) {
System.out.println (ele)
}
`
Memory Analysis of 1.5.2 Array
1.5.3 Common operation of array
1.5.4 array sorting
* * Select sort * *
Fix a subscript, and then compare the elements corresponding to this subscript with the elements of each subscript that follow.
```java
Int [] array = {1,3,5,7,9,0,8,6,4,2}
For (int index = 0; index < array.length-1; index++) {
For (int compare = index + 1; compare < array.length; compare++) {
If (array [index] < array [compare]) {
Int temp = array [index]
Array [index] = array [compare]
Array [compare] = temp
}
}
}
`
* * Bubble sort * *
Compare two adjacent elements in an array in turn
```java
Int [] array = {1,3,5,7,9,0,8,6,4,2}
For (int I = 0; I < array.length; iTunes +) {
For (int j = 0; j < array.length-1-I; jacks +) {
If (array [j] < array [j + 1]) {
Int temp = array [j]
Array [j] = array [j + 1]
Array [j + 1] = temp
}
}
}
`
1.5.5 Array element lookup
Query the subscript that appears for the specified element from an array
1. Sequential search
two。 Binary search
1.5.6 two-dimensional array
Thank you for your reading. the above is the content of "how to use big data array". After the study of this article, I believe you have a deeper understanding of how to use big data array, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.