毫无疑问,我错过了一些非常明显的东西,但我无法弄明白.任何帮助,将不胜感激.错误来自这里:
package B00166353_Grades;
public class Student{
String name,banner;
public Student(String name,String banner){
this.name=name;
this.banner=banner;
}
public String toString(){
String productDetails=new String();
productDetails+=String.format("%-20s%10.2s%10s",this.name,this.banner);
return productDetails;
}
}
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个包含多个学生对象的模块类,并且遇到了以下问题 -
一元运算符'+'的坏操作数类型字符串
我将不胜感激,我的代码如下.
public class Module {
private String moduleTitle;
int percentageCoursework;
int percentageExam;
private Student studentsList[] = new Student[3];
public Module (String moduleTitle, int percentageCoursework, int percentageExam,String studentOne, String studentTwo, String studentThree, String studentsTitles[])
{
this.moduleTitle = moduleTitle;
this.percentageCoursework = percentageCoursework;
this.percentageExam = percentageExam;
this.studentsList[0].name = studentOne;
this.studentsList[1].name = studentTwo;
this.studentsList[2].name = studentThree;
}
public void ShowDetails()
{
System.out.println("moduleTitle : " + moduleTitle +
"\n percentageCoursework : " + percentageCoursework +
"\n percentageExam : " + percentageExam + …
Run Code Online (Sandbox Code Playgroud)