title: Take a specific Line from an Arraylist and work with it
body: <p>I have to make a Quiz where the program takes a random question from a text file. I have made the program  to take a question from the file but I don't know how to make it take it randomly.</p>
  <p>Questions are formed like this:</p>
  <pre><code>How many countries are currently members of the United Nations?,A:190,B:191,C:192,D:193,D,d                         
  The atmosphere is held to the earth by _?A:Atoms,B:Molecules,C:Pressure,D:Gravity,D,d 
  </code></pre>
  <p>so I split them with &quot;,&quot;, and the last 2 words are the answer.
  I tried a lot of different ways but it is just out of my league.
  So if i have 50 questions in the file for example it should take only 10 at random and it should not take the same question 2 times, which is even harder to do</p>
  <pre><code>public static void main(String[] args) throws FileNotFoundException {
      try {
  
          String words[];
          int scorer=0;
          int scorew=0;
  
          Scanner scanner=new Scanner(System.in);
          FileReader fr = new FileReader(&quot;quiz_questions.txt&quot;);
          Scanner scan = new Scanner(fr);
  
          ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
          while (scan.hasNext()) 
          {
              list.add(scan.nextLine());
  
          }
  
          for(int i=0;i&lt;list.size();i++){
  
              words=list.get(i).split(&quot;,&quot;);
  
              for(int j=0;j&lt;words.length-2;j++){
  
                  System.out.println(words[j]);
              }
  
              String ans=scanner.nextLine();
  
              if(words[5].equals(ans) || (words[6].equals(ans))){
  
                  System.out.println(&quot;Antwort ist Richtig&quot;);              
                  scorer++;           
              }
  
              else{
                  System.out.println(&quot;Antwort ist Falsch&quot;);
                  scorew++;
              }
          }
  
          System.out.println(&quot;Du hast &quot; + scorer +&quot; Fragen richtig beantwortet und &quot;+ scorew + &quot; Fragen falsch beantwortet&quot;);
          scan.close();
          scanner.close();
          
      } catch (FileNotFoundException e) {
          System.out.println(&quot;Datei nicht gefunden bitte prufen&quot;);
      }
  }
  </code></pre>