gpt4 book ai didi

Java 测试失败(tostring)

转载 作者:行者123 更新时间:2023-12-02 17:49:13 26 4
gpt4 key购买 nike

我有这个 Java 程序,但我的测试给了我这样的消息:

testEmployeeTostring: failed testEmployeeTostring expected <[id[= 1013, name= Jubal Early, job = ]procurement]> but was: <[id[= 1013, name= Jubal Early, job = ] procurement]>

我必须使用@Override,我认为这就是问题所在。我希望有人能解决这个问题:

public class Employee {

int id;
String name;
JobType job;

public Employee(int id, String name, JobType job)
{
this.id = id;
this.name = name;
this.job = job;
}

@Override public String toString()
{
return ("["+ "id =" + id + ", name = " + name + ", job = " + job + "]");
}
}

最佳答案

] 和“采购”之间有一个空格

工作=]采购

关于Java 测试失败(tostring),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12680466/

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