public class han
{
public static void main(String[] args)
{
int c = jia(100); //这里的100写成num就出错 但这里随便写数字 这行c赋值都是5怎么回事?
int b=10;
c=c+b;
System.out.println(c);
}
public static int jia(int num)
{
return num=5;
}
}
我这里的 num=5 也是表达式吧 像那样的是返回int类型作者: wudongzhe 时间: 2012-11-25 11:10
public class han
{
public static void main(String[] args)
{
int c = jia(100); //这里的100写成num就出错 但这里随便写数字 这行c赋值都是5怎么回事?
int b=10;
c=c+b;
System.out.println(c);
}
public static int jia(int num)
{
return num=5;
}
}
我这里的 num=5 也是表达式吧 像那样的是返回int类型 作者: 潘天功 时间: 2012-11-25 11:50
eatdefecat 发表于 2012-11-25 11:10
public class han
{
public static void main(String[] args)
你这里只能返回num、即return num
在主方法调用时你可以把num进行赋值,随便传一个数就行,但不能再把num写上了
因为你调用的是jia()方法、方法中已经定义好了你想要的功能。你只要把你想打印的输入就行作者: super_Xiong 时间: 2012-11-25 19:20