java – invalid method declaration; return type required

In your method setDetails you haven’t specified anything for the return type, if it is not returning anything then specify void

For Voter class

public void setDetails(String name, int votNum, int precint)

for Candidates class

public void setDetails (String candName, int position, int totalVotes)

One other thing, (Thanks to Frank Pavageau) your class name is Candidates and you have defined the constructor with Candidate without s, that is why it is being considered as a normal method, and thus should have a return type. You your rename your constructor as Candidates, or rename your class as Candidate which is better.

Leave a Comment