**结束。**此问题需要详细的调试信息。它目前不接受答案。
**想改进这个问题吗?**更新问题,使其成为堆栈溢出的主题。
四年前关门了。
改进这个问题
//Caleb Howe Homework 5
public class MyStudent {
public static void main(String[] args) {
//Output print
Individual mine = new Individual();
System.out.println("The last name of the "+ "student is " + mine.lname + " and the first name is " + mine.fname);
System.out.println("The email address is " + mine.getemail());
System.out.println("The UUID is " + mine.getUUID());
System.out.println("-----------------------------------------");
Individual Student2= new Individual("Jones", "John", "BITS", "Senior","3.5");
System.out.println("The name of the Student is "+ Student2.fname+" "+Student2.lname);
System.out.println("The email of the student is " +Student2.getemail());
System.out.println("The GPA of the student is "+ Student2.gpa1);
System.out.println("The major of the student is "+ Student2.qualification);
System.out.println("The Student is a "+ Student2.year1);
System.out.println("Press any key to continue . . .");
}
}
//class template for student
class Individual{
//data for students
String fname = "Caleb";
String lname = "Howe";
String qualification;
String department;
String year1;
String gpa1;
// constructor (bare minimum)
public Individual(){
}
//constructor
public Individual(String last, String first, String BBA, String year, String gpa){
lname = last;
fname = first;
qualification = BBA;
year1 = year;
gpa1=gpa;
}
//constructor
public String getemail(){
String value = "default";
int amount;
value = fname;
String email = "default";
email = value.charAt(0)+lname+"@memphis.edu";
return email;
}
//constructor
public String getUUID(){
String id = "";
int number;
number = (int) ((Math.random()*100)+1.00);
id = number +fname.substring(0,1) + lname.substring(0, 1);
}
}
当我编译它时,由于分号的原因,它给了我一个语法错误。
不知道为什么,任何帮助都将不胜感激!
2条答案
按热度按时间6qftjkof1#
你的
getUUID()
方法被定义为返回String
但你从来没有return
什么都行。你可能想加上return id;
. 还有,你有几个//constructor
不作为构造函数的方法的注解。vmdwslir2#
整理你的缩进,给变量一个有意义的名字。他们会在现在和将来更好地帮助你。
getemail和getuuid也不是构造函数,它们需要返回值。构造函数必须与类同名。