Question: I have two ArrayLists of different size.

```
ArrayList<String> names = new ArrayList<String>();
ArrayList<User> users = new ArrayList<User>();

```

User is an Object with attributes name and address. I want to get the addresses where the names of the User object stored in ArrayList users is the same as the names stored in the ArrayList names.

Is this possible? If so, how?

Answer: 
```
for (User u : users) {
  if (names.contains(u.getName()) {
    System.out.println("Name: " + u.getName() + ", address: " + u.getAddress());
  }
}

```
You can use Java 8. 

Please try:

```
users.stream().filter(u -> names.contains(u.getName())).map(
                u -> "Name: " + u.getName() + ", address: " + u. getAddress()).forEach(System.out::println);

```