How do you create a list l and then access a random element of that list?


1 | java.util.List list = new java.util.ArrayList(); |
1 2 | import java.util.List; import java.util.ArrayLIst; |
1 | List list = new ArrayList(); |
1 | if ( ! list.isEmpty() ) |
1 2 3 | Object obj = null ; // for element from list if ( ! list.isEmpty() ) obj = list.get( Greenfoot.getRandomNumber( list.size() ) ); if ( obj != null ) // etc. |