Hi,I have a question ,which one is a better way to set constructor

public Employee(String name,double hours,double perHour,Date dateOfHire){
		 id=++count;
		 setName(name);
		 setHours(hours);
		 setPerHour(perHour);
		 this.dateOfHire=new Date();
	}

or

public Employee(String name,double hours,double perHour,int day,int month,int year){
		this(name, hours, perHour, new Date(day,month,year) );

Recommended Answers

All 2 Replies

if returns same value, no idea

As said, its the same thing. but I would go for 1st choice. Why? Simply because its better looking, and easier for recognizing parameters.
But its up to you which one you will pick.
Mitja

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.