-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTwoDArray.java
More file actions
46 lines (32 loc) · 777 Bytes
/
Copy pathTwoDArray.java
File metadata and controls
46 lines (32 loc) · 777 Bytes
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
public class TwoDArray {
public static void main(String[] args) {
String[][] states = new String[4][2];
states[0][0] = "California";
states[0][1]= "sacramento";
states[1][0] = "Oregon";
states[1][1]= "Salem";
states[2][0] = "Washington";
states[2][1]= "Olympia";
states[3][0] = "Extra";
states[3][1]= "VALUE";
for (int i = 0; i < states.length; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < states[i].length; j++) {
if (j == 0) {
sb.append("The State of ");
}
else{
sb.append(" is " );
}
sb.append(states[i][j]);
}
System.out.println(sb);
}
// for (int i = 0; i < states.length; i++) {
// //System.out.println(i);
// for (int j = 0; j < states[i].length; j++) {
// System.out.println(states[i][j]);
// }
// }
}
}