I have two classes in the same directory. However, i get a ‘constructor classA in class classA cannot be applied to given types.
In classA, there is one constructor which takes four parameters: String a, String b, String c and int A.
public classA(String s1, String s2, String s3, int i1){
this.sA = s1;
this.iA = i1
this.sB = s2;
this.sC = s3;
}
However, in my other class, when I try to compile classB, I get the following error:
classB.java:73: error: constructor classA in class classA cannot be applied to given types;
return new classA("e", "a", "f", 2);
^
required: no arguments
found: String,String,String,int
reason: actual and formal argument lists differ in length
I am confused why i get this error as there is only one constructor in the class and the type and order of arguments are given correctly. There is not an empty default constructor in classA.
mark2349 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1