import java.util.*;
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedHashSet<String> hs = new LinkedHashSet<String>();
hs.add("Digital");
hs.add("India");
System.out.println("The value of hs is " +hs);
for(String s : hs){
System.out.println("the value of s is " +s);
}
Iterator<String> it = hs.iterator();
while(it.hasNext()){
System.out.println("the value through iterator is " +(String)it.next());
}
}
}
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedHashSet<String> hs = new LinkedHashSet<String>();
hs.add("Digital");
hs.add("India");
System.out.println("The value of hs is " +hs);
for(String s : hs){
System.out.println("the value of s is " +s);
}
Iterator<String> it = hs.iterator();
while(it.hasNext()){
System.out.println("the value through iterator is " +(String)it.next());
}
}
}
output:-
The value of hs is [Digital, India]
the value of s is Digital
the value of s is India
the value through iterator is Digital
the value through iterator is India
No comments:
Post a Comment