-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFor_each_loop.java
More file actions
37 lines (28 loc) · 884 Bytes
/
For_each_loop.java
File metadata and controls
37 lines (28 loc) · 884 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
package com.company;
public class For_each_loop {
public static void main(String[] args) {
/* int[] marks ={23,54,65,57,54};
String[] students = {"LOL","OK","BADHIYA"};
System.out.println(students.length);
*/
int[] marks ={23,54,65,57,54};
//System.out.println(marks.length);
//1. Display the array (naive way) :
// System.out.println(marks[2]);
// System.out.println(marks[3]);
// System.out.println(marks[3]);
//
//2. Using For loop
// for (int i = 0; i!=marks.length; i++){
// System.out.println(marks[i]);
// }
//Problem 1
// for (int i = 0; i!=marks.length ; i++){
// System.out.println(marks[i]);
// }
//3. Using for each loop
for (int element: marks){
System.out.println(element);
}
}
}