Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1713011342--许超 #44

Open
DreamMemory001 opened this issue Dec 6, 2017 · 0 comments
Open

1713011342--许超 #44

DreamMemory001 opened this issue Dec 6, 2017 · 0 comments

Comments

@DreamMemory001
Copy link

DreamMemory001 commented Dec 6, 2017

import java.util.ArrayList;
import java.util.Iterator;

public class getData {
    public static   void main(String[] args) {
        ArrayList<String> gd = new ArrayList<>();
        gd.add("xiaomei");
        gd.add("jiahao");
        gd.add("xc");
        gd.add("wrf");
        gd.add("chengzhang");
        gd.add("zilong");
        gd.add("huifeng");
        gd.add("yuxin");
        gd.add("xiaoxia");
        gd.add("dingjiang");


        //方法一
        Iterator it = gd.iterator();// 获取迭代器
        while (it.hasNext()) {
            System.out.println(it.next());
        }


        //方法二
        for(Iterator iq = gd.iterator(); iq.hasNext();)
        {
            System.out.println(it.next());
        }

        // 方法三
        for (Object obj:gd
                ) {
            String string = (String )obj;
            System.out.println(string);
            if ( string.equals("xiaoxia"))
            {
                gd.remove(string);
            }
        }
        System.out.println(gd);

        // 方法四

        gd.stream().forEach(p -> System.out.println(gd));
    }
}
@DreamMemory001 DreamMemory001 changed the title 1713011342 1713011342--许超 Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant