为什么return语句没有打印到控制台? [英] Why does the return statement not print anything to the console?

查看:485
本文介绍了为什么return语句没有打印到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用谷歌搜索它并没有打出任何有用的东西,所以我决定在这里问一下。
我不能将System.out.println用于我正在处理的项目,所以我使用了return语句。一切都编译得很好,但我的return语句不会向控制台打印任何内容,程序就会终止。我在代码中所拥有的只是一个返回true或false的if-else语句。为什么我在控制台上看不到任何东西?
我顺便使用Eclipse Juno的控制台。

I Googled it and I didn't hit anything useful, so I decided to ask on here. I can't use System.out.println for the project that I am working on, so I used the return statement. Everything compiles just fine, but my return statement doesn't print anything to the console, the program just terminates. All I have in the code is just an if-else statement that returns true or false. Why don't I see anything on the console? I am using Eclipse Juno's Console by the way.

推荐答案

返回只是从方法返回一个值,它不打印它。您需要使用 System.out 方法或类似方法。

Return just returns a value from a method, it doesn't print it. You'll need to use the System.out method or something similar.

这篇关于为什么return语句没有打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆