0

そこで、約 20 個の変数を取るクラスを持つプログラムを作成しています (このクラスを Person と呼びましょう)。次のように変数を初期化しようとすると:

Person Steph = new Person(SName, SAge, SPhysical, SJob, SEducation, SPastSecret, SSecret1, Secret2, SSecret3, SConnections, SLikes, SHates, SCondtion, SNAME, SAGE, SPHYSICAL, SJOB, SEDUCATION, SPASTSECRET, SSECRET1, SECRET2, SSECRET3, SCONNECTIONS);

エラーが発生します:

internal error; cannot instantiate Person.<init> at Person to 

次に、変数をリストします。このエラーの原因を知っている人はいますか?

編集: Person の完全なコードは次のとおりです。

class Person extends Detect{
public String Name, Age, Physical, Job, Education, PastSecret, Secret1, Secret2, Secret3, Connections, Likes, Hates, Condition;
public boolean NAME, AGE, PHYSICAL, JOB, EDUCATION, PASTSECRET, SECRET1, SECRET2, SECRET3, CONNETCTIONS, LIKES, HATES, CONDITION;

public Person(String Name, String Age, String Physical, String Job, String Education, 
String PastSecret, String Secret1, String Secret2, String Secret3, String Connections, String Likes, 
String Hates, String Condition, boolean NAME, boolean AGE, boolean PHYSICAL, boolean JOB, boolean EDUCATION,
boolean PASTSECRET, boolean SECRET1, boolean SECRET2, boolean SECRET3, boolean CONNECTIONS, 
boolean LIKES, boolean HATES, boolean CONDITION) {

    this.Name = Name;
    this.Age = Age;
    this.Physical = Physical;
    this.Job = Job;
    this.Education = Education;
    this.PastSecret = PastSecret;
    this.Secret1 = Secret1;
    this.Secret2 = Secret2;
    this.Secret3 = Secret3;     
    this.Connections = Connections;
    this.Likes = Likes;
    this.Hates = Hates;
    this.Condition = Condition;
    this.NAME = NAME;
    this.AGE = AGE;
    this.PHYSICAL = PHYSICAL;
    this.JOB = JOB;
    this.EDUCATION = EDUCATION;
    this.PASTSECRET = PASTSECRET;
    this.SECRET1 = SECRET1;
    this.SECRET2 = SECRET2;
    this.SECRET3 = SECRET3;
    this.CONNECTIONS = CONNECTIONS;
    this.LIKES = LIKES;
    this.HATES = HATES;
    this.CONDITION = CONDITION;

}



public void File(){
    System.out.printf("Suspect Name: %s         Age: %s       Appearance: %s\n", Check(NAME, Name), Check(AGE, Age),
        Check(PHYSICAL, Physical));
    System.out.printf("Job: %s          Education: %s           Past Secret: %s\n", Check(JOB, Job), Check(EDUCATION, Education), 
        Check(PASTSECRET, PastSecret));
    System.out.printf("Connections: %s    Secret: %s      Secret: %s    Secret: %s\n", Check(CONNECTIONS, Connections), Check(SECRET1, Secret1),
        Check(SECRET2, Secret2), Check(SECRET3, Secret3));
    System.out.printf("Likes: %s    Hates: %s    Conditions: %s\n\n", Check(LIKES, Likes), Check(HATES, Hates), Check(CONDITIONS, Conditions));
}

}

4

3 に答える 3

4

26 個のパラメーターを持つコンストラクターに 23 個のパラメーターを渡しています。

于 2012-07-19T16:09:58.963 に答える
1

Person.<init>Personクラスのコンストラクターを指します。

エラーは、Personクラスのコンストラクターが、指定しているパラメーターと一致しないことを示しています。残念ながら、その理由はわかりません。

Eclipseなどの統合開発環境(IDE)をダウンロードしてインストールすることをお勧めします。これにより、このようなプログラミングの問題に関するより多くの情報が得られ、コーディングがはるかに簡単になります。

于 2012-07-19T16:13:05.303 に答える