title: How To Randomly Generate From A Given List?
body: <p>The problem I'm running into is to randomly generate names from a specific list. I want my program to be able to only pick from these names: <em>Bob, Jill, Tom</em>, and <em>Brandon</em>. I tried studying arrays but I think that's a bit too far for me to learn yet. So far I think I have a general idea, but I'm not sure.</p>
  
  <pre><code>import java.util.Random;
  
  public class NameGenerator
  {
  
          public static void main(String[] args)
          {
  
             System.out.println("This is a program that generates random names from a list!");
  
             int Bob = 0;
             int Jill = 0;
             int Tom = 0;
             int Brandon = 0;
             Random r = new Random();
  </code></pre>
  
  <p>After that I'm kind of stuck on how to get the generator going.</p>
  
  <p>Update:
  Well I took your advices and tried learning arrays. So far this is what I have.</p>
  
  <pre><code>ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
  names.add("Bob");
  names.add("Jill");
  names.add("Tom");
  names.add("Brandon");
  
  char index = randomGenerator.nextChar(names.size());
  String anynames = names.get(index);
  System.out.println("Your random name is" + anynames + "now!");
  </code></pre>
  
  <p>However now it says randomGenerator cannot be resolved and void methods cannot return a value. Any ideas on where I went wrong?</p>