collection interface

Commonly used collection classes

For details, see https://blog.csdn.net/qq_27231343/article/details/52255885Blogger introduction

Create the Muster class, instantiate the collection object in the main method, add elements to the collection, and finally output the objects in the collection as String:

package qsc.jike1504.hunu;
import java.util.*;
public class Muster {
public static void main(String args[]){
Collection list = new ArrayList();
list.add("a");
list.add("b");
list.add("c");
Iterator it =                                             list.iterator();
while(it.hasNext()){
String str =  (String)it.next();
System.out.println(str);
}
    }
}
                                        



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324531189&siteId=291194637