gpt4 book ai didi

Java:构造函数如何返回值?

转载 作者:太空狗 更新时间:2023-10-29 22:41:56 27 4
gpt4 key购买 nike

<分区>

$ cat Const.java 
public class Const {
String Const(String hello) {
return hello;
}
public static void main(String[] args) {
System.out.println(new Const("Hello!"));
}
}
$ javac Const.java
Const.java:7: cannot find symbol
symbol : constructor Const(java.lang.String)
location: class Const
System.out.println(new Const("Hello!"));
^
1 error

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