Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Iterator;
- import java.util.List;
- public class zad2 {
- public static void main(String[] args) {
- String[] friends = {"Jan", "Kasia", "Piotr", "Iza", "Gienek"};
- System.out.println(friends[0]);
- List<String> friendList = new ArrayList<>();
- for (String imie: friends)
- {
- friendList.add(imie);
- }
- String[] newFriends = {"Iza", "Gienek"};
- List<String> newFriendList = new ArrayList<>();
- for (String imie: newFriends)
- {
- newFriendList.add(imie);
- }
- editList(friendList, newFriendList);
- for (int i = 0; i< friendList.size(); i++)
- {
- System.out.printf("%s ", friendList.get(i));
- }
- }
- public static void editList(Collection<String> l1, Collection<String> l2)
- {
- Iterator<String> it = l1.iterator();
- while (it.hasNext())
- {
- if (l2.contains(it.next()))
- it.remove();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement