2021年1月21日星期四

How can I loop through multiple object in java

Hello I'm pretty new to java development and I'm having trouble with for loop Here is my code

        for (MatchTeam team : players) {          for (MatchPlayer player : team.getTeamPlayers()) {              for (Location location : arena.getLocations()) {                  player.getPlayer().teleport(location);              }          }      }  

Object MatchTeam is holding a list of player (getTeamPlayers) and getLocations contain two different location

I've tested this code with two player and they get teleported to the same location but they should get teleported to two different location

Any idea on how to resolve this ? Thanks !!

https://stackoverflow.com/questions/65837922/how-can-i-loop-through-multiple-object-in-java January 22, 2021 at 08:55AM

没有评论:

发表评论