Ok, I have no idea how to use a class I created its probably really simple but I still cant figure it out

Person employee = new Employee("Tom Jones", "777 B Street", "408-888-9999", "tj@xyz.com", "Room 221", "$30450", (2, 8, 1987));

I am trying to use this with this class I created but I keep getting an error:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - no suitable constructor found for Employee(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,int,int,int)
constructor Employee.Employee(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,MyDate) is not applicable
(actual and formal argument lists differ in length)
constructor Employee.Employee() is not applicable
(actual and formal argument lists differ in length)
at test.main(test.java:20)

AND HERE IS THE CLASS I AM USING, THanks for looking.

public class MyDate{
    private int month, day, year;
    
    public MyDate(){
    }
   
    public MyDate(int month, int day, int year){
        this.day = day;
        this.month = month;
        this.year = year;   
    }
}

Recommended Answers

All 2 Replies

If you want to pass an instance of your MyDate class as a parameter, you'll need to create it with 'new' keyword: new MyDate(...) .

If you want to pass an instance of your MyDate class as a parameter, you'll need to create it with 'new' keyword: new MyDate(...) .

Thank You so much, that was it perfect,

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.