title: How do I call methods from a class with an arraylist to another class?
body: <p>I'm in my first semester of Java and I need help in calling methods from the VotingMachine class below to the Candidate Class. The Voting Machine class is compiling properly. Thank you all for any help you can provide....
  Mercedes</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.ArrayList;
  
  /**
   * These are the fields for the Voting Machine Class.
   */
  public class VotingMachine
  {
      private ArrayList&lt;String&gt; candidateList;
  
      /**
       * The following constructor will establish the Candidate List
       */
      public VotingMachine()
      {
          candidateList = new ArrayList&lt;String&gt;();
      }
  
      /**
       * This constructor will store the Candidates for the Candidate List   
       */
      public void setCandidateList()
      {
          candidateList.add("Darnell Woffard");
          candidateList.add("Barack Obama");
          candidateList.add("Hillary Clinton");
      }    
  
      /**
       * This method will display the entire Candidate List.
       */
      public void printCandidateInfo()
      {
          for (int index=0; index &lt; candidateList.size(); index++)
          {
              System.out.println(candidateList.get(index));
          }
      }
  
      /**
       * Method to the number of Candidates in the CandidateList Arraylist.
       */
      public int getNumberofFiles()
      {
          return candidateList.size();       
      }
  
     /**
      * Method to select one candidate by first providing an index number.
      */
     public void listFile(int index)
     {
         if(index &gt;= 0 &amp;&amp; index &lt; candidateList.size()){
             String filename = candidateList.get(index);
             System.out.println(filename);
         }
     }
  
      /**
       * This method will enable a user to remove a candidate.
       */
      public void removeFile(int index)
      {
          if(index &gt;= 0 &amp;&amp; index &lt; candidateList.size()){
              candidateList.remove(index);
          }
      }
  
      /**
       * This method will add a file to the Candidate List.
       * 
       */
      public void addCandidate(String filename)
      {
         candidateList.add(filename);
      }
  
  
  //----------
  //The Candidate Class:
  
  public class Candidate{
  
      private String name;
      private char party;
      private String candidateList;
  // Add fields
      /**
       * Fields
       * name - Candidate's name, stored in a String
       * party - Candidate's political party, stored in a char
       * as 'r' for Republican, 'd' for Democrat, and 'i' for Independent
       */
  
      /**
       * Constructor
       * 
       * @param anyName - caller inputs Candidate name
       * @param anyParty - caller inputs Candidate's party affiliation
       * stored as a char
       * chars are assigned with single quotes.
       */
      public Candidate(String anyName, char anyParty)
      {
          name = anyName;
          party = anyParty;   
      }
  
      /**
       * The method will enable method calls from the Voting Machine Class.
       */
      public void main(String candidateList)
      {
          VotingMachine votingMachine = new VotingMachine();
      }
  
              /**
               * This method will define the candidates party affiliation.
               * public char setParty()
               */
  
  
  //Complete the three methods and their comments.    
      /**
       * Method to retrieve the Candidate's name for the caller.
       * public String getName(String anyName)
       * 
       */
  
  
  
      /**
       * Method to retrieve the Candidate's party for the caller.
       * 
       * @return
       */
  
  
  
      /**
       * Method to change the Candidate's party
       * 
       * @param 
       */
  </code></pre>