【发布时间】:2015-05-01 15:08:18
【问题描述】:
这是代码:
public class monkeyTrouble {
public static void main(String[]args){
monkeyTrouble s = new monkeyTrouble();
s.trouble(false, false);
}
public boolean trouble (boolean aSmile, boolean bSmile) {
if (aSmile == true && bSmile == true){
return true;
} else if (aSmile == false && bSmile == false) {
return true;
} else {
return false;
}
}
}
如何在 main 方法中运行 boolean 方法以使其正确运行?
【问题讨论】:
-
不知道你在这里正确运行是什么意思。你到底想让它做什么。如果你想用麻烦返回的值做一些事情,声明 boolean b = s.trouble(false,false);
-
我正在使用 eclipse 并且为了在这个编译器中运行一个程序。我必须有一个主要的方法。为了使用我的麻烦方法,我在 main 方法中放了什么?
标签: java methods boolean main void