In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Good programmer big data tutorials share practical arrays of big data
1.5.1 Array definition and element access
An array is a container that stores a specified data type.
Note:
An array is a container of fixed length. Once the instantiation is completed, the length cannot be modified.
The noun explains:
Array length: refers to the capacity of the container, indicating how many data elements can be stored in the array: refers to the data subscript stored in the array: an element is indexed in a position in the array to traverse the array: get each element in 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:
Use looping through the subscript
Int [] array = {1,2,3}; for (int index = 0; index < array.length; index++) {System.out.println (index);}
Use enhanced for loops
Int [] array = {1,2,3}; for (int ele: array) {System.out.println (ele);} memory analysis of 1.5.2 array common operations of 1.5.3 array 1.5.4 array sort
Select sort
Fix a subscript, and then compare the elements corresponding to this subscript with the elements of each subscript that follow.
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 }}}
Bubbling sort
Compare two adjacent elements in an array in turn
Int [] array = {1, 3, 5, 7, 9, 0, 8, 6, 4, 2}; for (int I = 0; I < array.length; iDeposit +) {for (int j = 0; j < array.length-1-I; jaun +) {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
Sequential search binary search 1.5.6 two-dimensional array
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.