Last active
November 28, 2016 19:22
-
-
Save dariuscouchard/d910206ccb1a6696560a4b1eb96fbbb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| public class YourClassNameHere { | |
| public static void main(String[] args) { | |
| ArrayList<Player> inGamePlayers = new ArrayList<Player>(); | |
| inGamePlayers.add(new Player("Griff")); | |
| String newUsername = "Polak"; | |
| for (Player p : inGamePlayers) { | |
| if (newUsername == p.username) { | |
| System.out.println(p.username+" reconnected!"); | |
| break; | |
| } | |
| inGamePlayers.add(new Player(newUsername)); | |
| } | |
| for (Player p : inGamePlayers) { | |
| System.out.println(p.username); | |
| } | |
| } | |
| } | |
| class Player { | |
| public String username; | |
| public Player(String username) { | |
| this.username = username; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment