I have a constructor:
Candidate(String name, int numVotes)
{
this.name = name;
this.numVotes = numVotes;
}
I've made an ArrayList of that class:
List <Candidate> election = new ArrayList<Candidate>();
I'm trying to add multiple objects of this class to the ArrayList. I've tried this, but it doesn't work:
election.add("John Smith", 5000);
election.add("Mary Miller", 4000);
It's throwing a compiler error stating:
The method add(int, Candidate) in the type List<Candidate> is not applicable for the arguments (String, int)
What am I doing wrong? Any help would be appreciated.