public class Curiosity {
public void toString()//error because of this specific method name
{
System.out.println("method is successfully implemented");
}
}
如果我愿意,如何使用同名的方法“toString()”?
我是否必须将其返回类型作为 String 如果不是我应该怎么做来更改它的返回类型,例如假设如果我想为 toString 使用 void 返回类型,java 是否允许这样做?