forked from mouredev/hello-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrays.java
More file actions
42 lines (29 loc) · 1 KB
/
Copy pathArrays.java
File metadata and controls
42 lines (29 loc) · 1 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
public class Arrays {
public static void main (String[] args) {
// Declaración y creación
int[] numbers = new int[3];
System.out.println(numbers);
String[] names = {"Hector", "Varon", "hvaron@gmail.com"};
System.out.println(names);
// Acceso
System.out.println(numbers[0]);
System.out.println(names[0]);
System.out.println((new String[3])[0]);
// Moodificación
numbers[0] = 1;
numbers[1] = 10;
System.out.println(numbers[0]);
System.out.println(numbers[1]);
// numbers[3] = 2; La posicion 3 no existe, Error
System.out.println(names[2]);
names[2] = "hvaron";
System.out.println(names[2]);
System.out.println(names.length);
names[2] = null;
System.out.println(names[2]);
System.out.println(names.length);
// numbers[2] = null; Error
boolean [] booleans = new boolean[5];
System.out.println(booleans[4]);
}
}