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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!