title: using count as index of string how to generate random words?
body: <p>I am writing a hangman program and I wanted to take word text file was working fine being able to populate an array list and generate a random word from the array-list. but i want to do something new. what the program is doing is fairly easy and straight forward it is reading a text file line by line and each time its reading a line it increments the count. but I want to generate a random word from that text file using the count value as index of a word in the text file. Can anyone please help me out with where can I get documentation about this problem?</p>
  
  <pre><code>public class WordReader {
  
  
      private static String fileName = "Wordlist.txt";
      int count = 0;
  
      public WordReader() throws FileNotFoundException {
          File file = new File(fileName);
          try(Scanner sc = new Scanner(new FileInputStream(file))){
              int count=0;
              while(sc.hasNext()){
                  sc.next();
                  count++;
              }
  
          }
      }
  }
  </code></pre>