Question
i am trying to code toString statement. i am getting the error in blue j when i compile constructor Employee in class cannot be applied
i am trying to code toString statement. i am getting the error in blue j when i compile
constructor Employee in class cannot be applied to given types
required java.lang string .int manager found: int,java,lang String
resason: actual argument int cannot be converted to java.lang.String by method invocation conversion,
my class code
public class Employee { // instance variables private String name; private int id; private Manager manager;
/** * Constructor for objects of class Employee */ public Employee( String name,int id, Manager manager) { // initialise instance variables super(); this.name = name; this.id = id; this.manager = manager; } /** * Getter for theemployee's manager. */ public Manager getManager() { return this.manager; } /** * Setter for a employee's manager. */ public void setManager(Manager manager) { this.manager = manager; }
/** * Getter for a employee's name. */ public String getName() { return this.name; } /** * Setter for a employee's name. */ public void setName(String name) { this.name = name; } /** * Getter for a employee's id. */ public int getId() { return this.id; } /** * Setter for a employee's id. */ public void setId(int id) { this.id = id; }
/** * Returns a string describing this object. */ @Override public String toString() { return name+" "+id+" "+manager; } // public static void main(String args[]){ Employee e1= new Employee(01,"Ari","John"); Employee e2=new Employee(02,"Jon","John"); System.out.println(e1); System.out.println(e2); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started