Constructor is undefined

Page 1 of 1

1 Replies - 88 Views - Last Post: 15 January 2013 - 02:25 PM Rate Topic: -----

#1 W1174503  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 07-January 13

Constructor is undefined

Posted 15 January 2013 - 02:23 PM

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;
	}
	
}


Is This A Good Question/Topic? 0
  • +

Replies To: Constructor is undefined

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon

Reputation: 5429
  • View blog
  • Posts: 8,745
  • Joined: 19-March 11

Re: Constructor is undefined

Posted 15 January 2013 - 02:25 PM

Duplicate topic, closing this one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1