Completely new to java, trying to figure out how to implement this code properly
I'm trying to implement something at the moment and am having issues doing so properly
So what I'm trying to do here is add this
Code:
public static Player getPlayer(String name) {
for (int i = 0; i < Config.MAX_PLAYERS; i++)
{
if (players[i] != null && players[i].playerName.equalsIgnoreCase(name))
{
return players[i];
}
}
Into this
Code:
public static Player getPlayer(String name) {
return Arrays.stream(players).filter(p -> p != null && p.playerName.equalsIgnoreCase(name)).findFirst().get();
}
I've tried just flat out replacing it but eclipse doesn't like that and tells me I need to return the type of player, but I have no idea what that means, how can I implement these together without breaking my code?
I hate to ask for spoonfeeding me but could someone also explain the process here for making it work properly? I'm trying my best to kind of learn as I go