-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForEachLoop.java
More file actions
36 lines (28 loc) · 778 Bytes
/
ForEachLoop.java
File metadata and controls
36 lines (28 loc) · 778 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 test;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class ForEachLoop {
public static void main(String[] args) {
String str = "Rahul";
char[] strChar = str.toCharArray();
for (char i : strChar)
System.out.print(i);
int[] num = {3, 5, 6, 7, 9, 10};
for (int j : num)
System.out.print(j);
Set<Character> set = new HashSet<>();
set.add('a');
set.add('b');
set.add('c');
set.add('d');
set.add('e');
for (char k : set)
System.out.print(k);
Iterator<Character> itr=set.iterator();
while(itr.hasNext())
{
System.out.print(itr.next());
}
}
}