-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElfNameArrayStandard.java
More file actions
30 lines (24 loc) · 950 Bytes
/
ElfNameArrayStandard.java
File metadata and controls
30 lines (24 loc) · 950 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
class ElfNameArrayStandard{
public static void main(String[] args){
String[] firstLetter = new String[26]; //assigning an array of size 26
//the following block of code assignes first 5 letters of the alphabet to their positions in array
firstLetter[0] = "a";
firstLetter[1] = "b";
firstLetter[2] = "c";
firstLetter[3] = "d";
firstLetter[4] = "e";
//ouputting first and last element of the array
System.out.println(firstLetter[0]);
System.out.println(firstLetter[25]);
String[] month = new String[12]; //assigning an array of size 12
//the following block of code assignes first 5 months to their positions in array
month[0] = "January";
month[1] = "Febrary";
month[2] = "March";
month[3] = "April";
month[4] = "May";
for(int i = 0; i < month.length; i++){ //outputting each value of the array
System.out.println(month[i]);
}
}
}