gpt4 book ai didi

java - 为什么最后一行出现语法错误?

转载 作者:行者123 更新时间:2023-12-02 11:13:48 25 4
gpt4 key购买 nike

关闭。这个问题需要debugging details .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

6年前关闭。




Improve this question



//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);
}
}

当我编译它时,由于分号,它给了我一个语法错误。
无法弄清楚为什么,任何帮助将不胜感激!

最佳答案

您的 getUUID()方法定义为返回 String ,但你从来没有return任何事物。您可能打算添加 return id; .另外,你有几个 //constructor不作为构造函数的方法的注释。

关于java - 为什么最后一行出现语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36266443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com