Home > Back-end >  Compile times wrong shows no suitable constructor should be how to solve?
Compile times wrong shows no suitable constructor should be how to solve?

Time:10-06

import java.util.Scanner;
Public class teat3 {
Public static void main (String [] args) {
Scanner in=new Scanner (System. In);
System. The out. Println (" please input the number of the students: ");
Int renshu=in nextInt ();
System. The out. Println (" please enter the course number ");
Int courcsNum=in nextInt ();
String [] name=new String (renshu);
String [] courcs=new String (courcsNum);
Int [] [] number=new int [renshu] [courcsNum];
Int [] sum=new int [renshu];
Int [] avg=new int [renshu];
String STR=new String [] [renshu];
for(int i=0; i{
System. The out. Println (" please define the first "+ (I + 1) + the name of the" course ");
Courcs=[I] in the next ();
}
for(int i=0; i{
Int s=0;
System. The out. Println (" please enter the student's name: ");
Name=[I] in the next ();
String str11="";
for(int j=0; jSystem. Out. Println (" please input the students "+ name + [I] courcs [j] +" result ");
Number. [I] [j]=in nextInt ();
S +=number [I] [j].
Str11 +=number [I] [j] + "\ t";
}
The sum [I]=s;
Avg [I]=s/courcsNum;
STR=name [I] [I] + "\ t" + str11 + sum [I] + "\ t" + avg [I];

}
for(int i=0; i{
for(int j=0; jIf (sum [j] Int t1=sum [j]; String t2=STR [j];
[j]=sum sum [j + 1); STR [j]=STR [j + 1);
The sum [j + 1)=t1; STR [j + 1)=t2;
}
}
}
System. The out. Print (" students ");
for(int i=0; i{
System. The out. Print (" \ t "+ courcs [I]);
}
System. The out. Print (" list "scored an average total score \ t \ \ t t);
System.out.println();
for(int i=0; iSystem. The out. Println (STR + "\ t the first" [I] + (I + 1) + "name");
}
}
}
For the String (int), can not find the appropriate constructor
String [] name=new String (renshu);
^
Constructor String. The String () is not applicable to
Length (the actual parameter list and the formal parameter list)
Constructor String. The String (String) shall not apply to the
(parameters does not match; Int cannot be converted to String)
The constructor String. The String (char []) shall not apply to the
(parameters does not match; Int cannot be converted to char [])
Constructor String. String (char [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (int [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, String) shall not apply to the
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, Charset) shall not apply to the
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], String) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Constructor String. String (byte [], Charset) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Constructor String. String (byte [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte []) shall not apply to the
(parameters does not match; Int cannot be converted into byte [])
Constructor String. String (StringBuffer) shall not apply to the
(parameters does not match; Int cannot be converted to StringBuffer)
Constructor String. String (StringBuilder) shall not apply to the
(parameters does not match; Int cannot be converted to the StringBuilder)
The constructor String. String (char [], Boolean) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Teat3. Java: 10: error: String (int), can not find a suitable constructor
String [] courcs=new String (courcsNum);
^
Constructor String. The String () is not applicable to
Length (the actual parameter list and the formal parameter list)
Constructor String. The String (String) shall not apply to the
(parameters does not match; Int cannot be converted to String)
The constructor String. The String (char []) shall not apply to the
(parameters does not match; Int cannot be converted to char [])
Constructor String. String (char [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (int [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, String) shall not apply to the
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], int, int, Charset) shall not apply to the
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte [], String) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Constructor String. String (byte [], Charset) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Constructor String. String (byte [], int, int) is not applicable to
Length (the actual parameter list and the formal parameter list)
The constructor String. String (byte []) shall not apply to the
(parameters does not match; Int cannot be converted into byte [])
Constructor String. String (StringBuffer) shall not apply to the
(parameters does not match; Int cannot be converted to StringBuffer)
Constructor String. String (StringBuilder) shall not apply to the
(parameters does not match; Int cannot be converted to the StringBuilder)
The constructor String. String (char [], Boolean) shall not apply to the
Length (the actual parameter list and the formal parameter list)
Two mistakes

CodePudding user response:

Do homework do stupid someone answer? thank you

CodePudding user response:

String [] name=new String (renshu);//this array on the left, the right is a String object, can type different assignment?
Change
String [] name=new String [renshu];//on the right side of the new array object also

Similarly
String [] courcs=new String (courcsNum);
Also to
String [] courcs=new String [courcsNum];
  • Related