Reputation: 11
package testing;
public class Clerk {
private String name;
private double score;
private Clerk clerk;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public double getScore(){
return score;
}
public void setscore(double score){
this.score=score;
}
public Clerk(String name, double score){
this.name=name;
this.score=score;
}
public void Clerk(String name, double score){
clerk.add(clerk); //i am getting the error here
}
The error stated is "cannot find symbol". I am not sure what I'm doing wrong. Much help is appreciated.
Upvotes: 1
Views: 76
Reputation: 380
There is no valid reason to name the method with the class name. As said here Methods With Same Name as Constructor - Why? it will be considered a bad practice. Try to rewrite your code like this:
public void setClerk(Clerk clerk){
this.clerk = clerk;
}
public Clerk getClerk(){
return clerk;
}
Upvotes: 1
Reputation: 681
There is no method add
in that class Clerk.
To make it compile add:
private void add(Clerk clerk) {
//do something
}
Upvotes: 1