Java OOP プロジェクトで、コンストラクターで 3 つのエラーが発生しました。
.\Voter.java:14: エラー: メソッド宣言が無効です。返品種別必須
.\Candidates.java:7: エラー: メソッド宣言が無効です。返品種別必須
.\Candidates.java:14: エラー: メソッド宣言が無効です。返品種別必須
コンストラクターのコード:
public class Voter{
private String name;
private int votNum;
private int precint;
public Voter(String name, int votNum, int precint)
{
this.name = name;
this.votNum = votNum;
this.precint = precint;
}
public setDetails(String name, int votNum, int precint)
{
this.name = name;
this.votNum = votNum;
this.precint = precint;
}...}
public class Candidates
{
public String candName;
private int position;
private int totalVotes;
public Candidate (String candName, int position, int totalVotes)
{
this.candName = candName;
this.position = position;
this.totalVotes = totalVotes;
}
public setDetails (String candName, int position, int totalVotes)
{
this.candName = candName;
this.position = position;
this.totalVotes = totalVotes;
}...}
私は次のようにコンストラクタを宣言しました:
public class MainClass{
public static void main(String[] args){
System.out.println("Previous voter's info: ");
Voter vot1 = new Voter("voter name", 131, 1);
System.out.println("The Candidates: ");
Candidates cand1 = new Candidates("candidate name", 1, 93);
}
}
見逃したものはありますか?