编译错误:“void”此处不允许输入
我该如何解决这种类型的编译错误。
粗体部分是显示编译错误的地方。
DegreeDays.java:71: 'void' type not allowed here
System.out.println(***"\t"***(error here) +
list(test[counter]) + "\t\t\t" +
average_temp(test[counter], test[counter - 1]));
DegreeDays.java:71: 'void' type not allowed here
System.out.println("\t" + list(test[counter]) ***+
***(error here) "\t\t\t" +
average_temp(test[counter], test[counter - 1]));
How can I resolve this type of a compilation error.
The bold part is the place where it shows a compilation error.
DegreeDays.java:71: 'void' type not allowed here
System.out.println(***"\t"***(error here) +
list(test[counter]) + "\t\t\t" +
average_temp(test[counter], test[counter - 1]));
DegreeDays.java:71: 'void' type not allowed here
System.out.println("\t" + list(test[counter]) ***+
***(error here) "\t\t\t" +
average_temp(test[counter], test[counter - 1]));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
想象一下:
答案是 explode - 这就是 javac 正确执行的操作。方法
foo
具有“void 结果类型”(none、nada、zilch)。没有返回任何对象。曾经。甚至不为空。没有“无”,编译器将拒绝尝试将“无”用作“有”。(具有“void 结果类型”的方法与可以返回
null
的方法不同——例如返回类型是Object——这样的方法仍然具有“非- void”结果类型。)快乐编码。
Imagine this:
The answer is explode - and this is what javac is correctly doing. The method
foo
has a "void result type" (none, nada, zilch). There is no object returned. Ever. Not even null. There is "nothing" and the compiler will refuse to try and use "nothing" as a "something".(A method with a "void result type" is different than a method which can return
null
-- e.g. return type is Object - such a method still has a "non-void" result type.)Happy coding.
看起来很可能
list
和average_temp
没有返回string
。It seems most likely that
list
andaverage_temp
aren't returning astring
.System.out.print()
必须需要显示一些内容。因此,如果您在其中编写任何不返回任何内容的void
方法,则会显示错误。所以在你的代码中:
我认为
average_temp
是void
类型。System.out.print()
must need something to show. So if you write anyvoid
method in it which doesn't return anything it will show error.So in your code:
I think
average_temp
is of typevoid
.您尝试打印方法 return Nothing (void)。
我认为这是
list()
方法检查它是否返回string
或void
..如果它返回
void
您必须从println
方法中删除它。you try to print method return Nothing (void).
I think it is
list()
method check if it's return astring
orvoid
..if it return
void
you have to delete it from theprintln
method..