oop – java – invalid method declaration; return type required

oop – java – invalid method declaration; return type required

In your method setDetails you havent 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.

Your Voter.setDetails function has no return type. If you dont want it to return specify the return type as void

public void setDetails(String name, int votNum, int precint)
{
    this.name = name;
    this.votNum = votNum;
    this.precint = precint;
}

oop – java – invalid method declaration; return type required

add a return type to all of your methods in your voter class.

Currently here in your code you have shown just one method showDetails() which has no return type. Certainly there will be other methods also for which you havent declared a return type.

Leave a Reply

Your email address will not be published.