Question: I have this function:

```
        playerList.forEach(pl ->{
            JSONObject player = (JSONObject) pl;
            System.out.println(player.get("UUID")+" : " + uuid+" :")

```

but there is an error on the line "return warps" that say "Unexpected return value".
Why is this happening?

Answer: 
Like what **am9417** mentioned, your return statement is inside the *forEach* scope which is a **void** function, hence the error you're getting.

Here are two options you can try and play around with:

1. Using streams. Here I used *filter* to get the item/s which matches the uuid criteria(argument in your example method). And then *findFirst* at the end to always get the first occurrence assuming you're expecting 1 UUID match all the time.

```java
// using findFirst returns an Optional type.
Optional<JSONObject> optionalPlayer = playerList
       .stream()
       .filter(pl -> {
           JSONObject player = (JSONObject) pl;
           System.out.println(player.get("UUID") + " : " + uuid + " :");
           return player.get("UUID").equals(uuid);
       }).findFirst();

if (optionalPlayer.isPresent()) {
   return (JSONArray) optionalPlayer.get().get("warps");
}

```

2. Using a simple for loop:

```java
JSONArray playerList = (JSONArray) obj;

for (Object pl: playerList) {
    JSONObject player = (JSONObject) pl;
    System.out.println(player.get("UUID") + " : " + uuid + " :");
    if (player.get("UUID").equals(uuid)) {
        return (JSONArray) player.get("warps");
    }
}

```
You are returning the warps inside an anonymous function (ForEach for playerList) so the signature for ForEach does not match, which gives the error.

You should use most likely `filter` and suitable terminator for your stream. Then just return the collected JSONArray from your `getWarps` method.