Hi I was wondering how I can print out one random value of an array instead of two of them. Here is my code:
public static void main(String args[])
{
String[] currentRoom;
String[][] rooms = new String [2] [2];
rooms [0] [0] = "Start";
rooms [0] [1] = "Treasure Room 1";
rooms [1] [0] = "Goblin Hive 1";
rooms [1] [1] = "Spider Nest";
Random rand = new Random();
{
currentRoom = rooms[rand.nextInt(rooms.length)];
System.out.println(Arrays.toString(currentRoom));
}
}
When I print it out it will say two values from my array, something like: ["Start", "Treasure Room1"] and I need it to print out just one value like: ["Start"] or just ["Spider Nest1"]. I was wondering how I can solve this.
Any help is appreciated:)