請幫忙解答下代碼中三個(gè)問號(hào)????
比如
public class HellWorld{
int a ? ? int b?
HelloWorld hello=new HelloWorld();//創(chuàng)建類得對象
hello.c(1,2);//類對象只有調(diào)用c方法之后才可以輸入實(shí)參?
c hello2=new c(1,2)//創(chuàng)建c方法對象的同時(shí)可以輸入實(shí)參?
public void (這個(gè)地方void沒寫是不是也代表沒返回值?)c (int c,int d) {?
a=c ?b=d
System.out.println(a,b);
}
2016-05-05
1、因?yàn)閏方法中需要兩個(gè)參數(shù),所以用hello對象調(diào)用c方法時(shí)必須有參數(shù)
2、創(chuàng)建hello2對象時(shí)也可以輸入實(shí)參,因?yàn)閏方法中需要兩個(gè)參數(shù)
3、void不能省略,構(gòu)造方法才要省略
2016-05-05
c=1,d=2;這里面的int c? int d? 只是形式參數(shù)
c括號(hào)后面的為方法? 所有帶()的都是方法
如果后面的void? 花括號(hào)里面就得有return c+d?? 而且前面還得表明返回值類型? int? (用來代替void)
2016-05-05
1、因?yàn)閏方法中需要兩個(gè)參數(shù),所以用hello對象調(diào)用c方法時(shí)必須有參數(shù)
2、創(chuàng)建hello2對象時(shí)也可以輸入實(shí)參,因?yàn)閏方法中需要兩個(gè)參數(shù)
3、void不能省略,它又不是構(gòu)造函數(shù)