forked from rahulXbarnwal/JavaTutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicsOfArray.java
More file actions
35 lines (27 loc) · 791 Bytes
/
BasicsOfArray.java
File metadata and controls
35 lines (27 loc) · 791 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
package arrays;
public class BasicsOfArray {
public static void main(String[] args) {
// int age[]; // declaration
// age = new int[5]; // allocation
// int age[] = new int[5];
//
// age[0] = 5;
// age[1] = 2;
//
// System.out.println(age[0]);
// System.out.println(age[1]);
// System.out.println(age[2]);
//
// System.out.println(age.length);
// int marks[] = {98, 12, 45, 12, 65};
//
// System.out.println(marks[0]);
String names[] = {"Rahul", "Prateek", "Mayank", "Ravi"};
for(int i = 0; i < names.length; i++) {
System.out.println("Name is " + names[i]);
}
for (String name: names) {
System.out.println("for each " + name);
}
}
}