-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic
More file actions
41 lines (35 loc) · 1.02 KB
/
basic
File metadata and controls
41 lines (35 loc) · 1.02 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
ARRAY
public class Main {
public static void main(String[] args) {
String[] cars = new String[3];
cars[0] = "Camaro";
cars[1] = "Corvette";
cars[2] = "Tesla";
for(int i=0; i<cars.length; i++){
System.out.println(cars[i]);
}
}
}
2D ARRAY
public class Main {
public static void main(String[] args) {
String[][] cars = {{"Camaro", "Corvette", "Silverado"},
{"Mustang", "Ranger", "F-150"},
{"Ferrari", "Lambo", "Tesla"}};
/*cars[0][0]="Camaro";
cars[0][1]="Corvette";
cars[0][2]="Silverado";
cars[1][0]="Mustang";
cars[1][1]="Ranger";
cars[1][2]="F-150]";
cars[2][0]="Ferrari";
cars[2][1] ="Lambo";
cars[2][2] ="Tesla";*/
for(int i=0; i<cars.length; i++){
System.out.println();
for(int j=0; j<cars[i].length; j++){
System.out.print(cars[i][j] + " ");
}
}
}
}