Eclipse allows me to fix the undefined constructor (line 4 of TestToString.java) by removing the arguments but that is not what I am trying to do. I am attempting to get the program to execute and say (Id is 1 The name is Fluffy). Can anyone please help?
public class TestToString {
public static void main(String[] args) {
ToString obj1 = new ToString(1, "Fluffy");
System.out.println(obj1.toString(obj1));
}
}
public class ToString {
private int iD;
private String name;
public void toString(int iDArg, String nameArg){
iD = iDArg;
name = nameArg;
}
public String toString(ToString Obj1) {
String ToString = "Id is " + iD + "The name is " + name;
return ToString;
}
}