The property you're looking for is "size".
ArrayList and arrays are different here in this aspect.You get the length of an array with "arr.length" and the length(or size) of an ArrayList with "arrList.size()".
Also to generate random index within the range of size you can use Random class's nextInt method.
Below is the code similar to what you're trying to do which picks random gifts and places for each friend.
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"}));
Random rand = new Random();//This is the Random class that can be used to generate random number. In this case Integers
//just a for loop iterating through all friends
//This will pick a random element from each of places and gifts
//You can get an element of a list by using the get
//method(arrList.get(index))
for(String friend : friends){
System.out.println(places.get(rand.nextInt(places.size())));
System.out.println(gifts.get(rand.nextInt(gifts.size())));
}
}
Edit : Added a more scalable way using Map since if you keep on increasing properties it'll be hectic to maintain.
Map<String, ArrayList<String>> mapOfProperties = new HashMap<>();
mapOfProperties.put("friends",Arrays.asList(new String[]{"Danny", "Benni", "Marcus", "Pat"}));
mapOfProperties.put("places",Arrays.asList(Arrays.asList(new String[]{"Paris", "Brasil", "Miami", "Jamaica"}));
mapOfProperties.put("gifts",Arrays.asList(new String[]{"Snacks", "Photos", "Instrument", "Whine"}));
Set<String> keysOfMap = mapOfProperties.keySet();
Random rand = new Random();
for(int i=0;i<map.get("friends").size();i++){
for(String keyName : keysOfMap){
int keyIndex = rand.nextInt(mapOfProperties.get(keyName).size());
//can put mapOfProperties.get(keyName) in a temp arrayList as well
System.out.print(mapOfProperties.get(keyName).get(keyIndex));
}
}
.Random()on the result of that .get() ??