Collection in Java
import java.util.ArrayList;
import java.util.Iterator;
public class CollectionTest {
public static void main(String[] args) {
ArrayList<String> name = new ArrayList<>();
name.add("PORAG");
name.add("FAISAL");
name.add("WASIM");
name.add("SAM");
name.add("SHUVO");
System.out.println("---- 1st Way -----");
for(String obj:name){
System.out.println(obj);
}
System.out.println("---- 2nd Way -----");
Iterator<String> iterator = name.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
}
}
View Source Code
import java.util.Iterator;
public class CollectionTest {
public static void main(String[] args) {
ArrayList<String> name = new ArrayList<>();
name.add("PORAG");
name.add("FAISAL");
name.add("WASIM");
name.add("SAM");
name.add("SHUVO");
System.out.println("---- 1st Way -----");
for(String obj:name){
System.out.println(obj);
}
System.out.println("---- 2nd Way -----");
Iterator<String> iterator = name.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
}
}
View Source Code
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন