-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArrayAllinone.java
More file actions
95 lines (63 loc) · 2.08 KB
/
Copy pathArrayAllinone.java
File metadata and controls
95 lines (63 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* @Author: r00x.tactx
* @Date: 2017-10-15 11:48:46
* @Last Modified by: xx.tactx
* @Last Modified time: 2017-10-15 15:53:47
Top 10 Methods for Java Arrays
*/
// package org.r00txx.tese;
import java.util.Arrays;
public class ArrayAllinone {
public static void main (String[] args) {
defileArray();
outputArray();
}
//define a array
public static void defileArray() {
String[] aArray = new String[5];
String[] bArray = {"a", "b", "c", "d", "e"};
String[] cArray = new String[]{"a", "b", "c", "d", "e"};
System.out.println("------------- defined array ----------------");
System.out.println(Arrays.toString(aArray));
System.out.println(Arrays.toString(bArray));
System.out.println(Arrays.toString(cArray));
}
public static void erweiArray() {
int[] arr1 = {1, 2, 3, 4, 5};
int[] arr2 = {6, 7, 8, 9, 10};
// ArrayList<int[]> = [arr1, arr2];
List<int[]> al = new ArrayList<int[]>();
al.add(arr1);
al.add(arr2);
}
public static void outputArray() {
System.out.println("------------- outpuy array ----------------");
int[] intArray = {1, 2, 3, 4, 5};
String intArrayString = Arrays.toString(intArray);
System.out.println(intArrayString);
}
public static void arrayToList() {
String[] stringArray = {"a", "b", "c", "d", "e"};
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
System.out.println(arrayList);
}
public static void checkExists() {
String[] stringArray = {"a", "b", "c", "d", "e"};
boolean b = Arrays.asList(stringArray).contains("a");
System.out.println(b);
}
public static void connectArray() {
int[] intArray = {1, 2, 3, 4, 5};
int[] intArray2 = {6, 7, 8, 9, 10};
int[] combinedintArray = ArrayUtils.addAll(intArray, intArray2);
}
public static void defineInlineArray() {
//method (new String[] {"a", "b", "c"});
}
public static void bytesArray() {
byte[] bytes = ByteBuffer.allocate(4).putlnt(8).array();
for (byte t : bytes) {
System.out.println("0x%x", t);
}
}
}