JAVA简单运算
程序代码:
public class TestType
{
public static void main(String args[])
{
int x = 10;
System.out.println( meth1(x+1) );
}
public static int meth1(int x)
{
return meth2(x)*2;
}
public static int meth2(int x)
{
return x+3;
}
}
这题我算来算去是27,可答案是28?{
public static void main(String args[])
{
int x = 10;
System.out.println( meth1(x+1) );
}
public static int meth1(int x)
{
return meth2(x)*2;
}
public static int meth2(int x)
{
return x+3;
}
}
----------------解决方案--------------------------------------------------------
x+1->11
meth2(11)->14
meth2(11)*2 ->28
----------------解决方案--------------------------------------------------------
答案怎么会是27呢?
x=10;
x+1=11;
x+1+3=14;
(x+1+3)*2=28...
----------------解决方案--------------------------------------------------------