Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use big data array

Shulou Source: shulou.com Published: 2022-06-01 09:29:12 09月11日 Update

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!

Tags: Arrays elements subscripts data containers that is storage learning sorting content length loop two items locations memory nouns nouns interpretation instances capacity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Docker vpn Redmi