jeudi 10 septembre 2020

How to print a string from an ArrayList of an ArrayList



import java.util.*;
import java.lang.*;
import java.io.*;


class Adventurers
{
    public static void main (String[] args) throws java.lang.Exception
    {
    public static void main (String[] args) throws java.lang.Exception{
            
    ArrayList<String> friends = new ArrayList<>(Arrays.asList(new String[]{"Danny", "Benni", "Marcus", "Pat"}));
    ArrayList<String> places = new ArrayList<>(Arrays.asList(new String[]{"Paris", "Brasil", "Miami", "Jamaica"}));
    ArrayList<String> gifts = new ArrayList<>(Arrays.asList(new String[]{"Snacks", "Photos", "Instrument", "Whine"}));
    ArrayList<String> events = new ArrayList<>(Arrays.asList(new String[]{"Zombie Tag ", "Bar tour"}));
    ArrayList<String> people = new ArrayList<>(Arrays.asList(new String[]{"Karen ", " Ryu ", " Darth Vader"}));
    ArrayList<String> animals = new ArrayList<>(Arrays.asList(new String[]{"Dog ", " Cat ", " Bird "}));
    
    ArrayList[] objectives = new ArrayList<>(Arrays.asList(new String[] {places, gifts, events, people, animals});
    
    
    

    

    for(String friend : friends){
        System.out.println(objectives.get(rand.nextInt(objectives.size())).get(rand.nextInt(this.size)));
        
     }
}
    }
}

Hello I'm trying to print a random message from an ArrayList of a master ArrayList as I'm trying to print a list of objectives per friend (another list). I figured out how to print them separately though I wanted to know if it was possible to print strings from a master ArrayList.




Aucun commentaire:

Enregistrer un commentaire