【发布时间】:2016-09-14 06:06:33
【问题描述】:
我是 Java 新手,所以我需要帮助。
如何访问方法method1 的变量并将它们与变量int c 进行比较?我应该返回什么?
public static void main (String [] args){
int c = 30;
// I want to compare c with a, for example:
if (c > a)
{
System.out.println(c + " is greater than " + a);
}
}
我想做上面的对比,不碰method1()
public double method1(){
int a = 10; int b = 20;
if (a > b)
{
System.out.println(a + " is greater than " + b);
}
else if (a < b)
{
System.out.println(b + " is greater than " + a);
}
//What should I return?
return ????;
}
【问题讨论】:
标签: java variables methods comparison access-modifiers