第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

主類怎么加進(jìn)去啊,代碼錯(cuò)了不會(huì)改

public class dog { int age =5; String name="樂樂"; String color="白色"; int weight =10; String sex="female"; void eat() { } void look() { } void yao() { } void run() { } void swim() { } {System.out.println("beef"); System.out.println("person"); System.out.println("旺旺~~~~~"); System.out.println("quick"); System.out.println("會(huì)"); } public class dog1 extends dog {public dog1(){ super(); }??? public class dog2 extends dog??? {public dog2(){??? this();??? ??? }??? }
??? public static void main (String args[]) { dog dog=new dog(); System.out.println("姓名:"+dog.name); System.out.println("年齡:"+dog.age); System.out.println("顏色:"+dog.color); System.out.println("體重:"+dog.weight); System.out.println("性別:"+dog.sex); dog.eat(); dog.look(); dog.yao(); dog.run(); dog.swim();}

正在回答

5 回答

public?class?Dog?{	
	int?age?=5;	
	String?name="樂樂";	
	String?color="白色";	
	int?weight?=10;	
	String?sex="female";	
	void?eat()	{	}	
	void?look()	{	}	
	void?yao()	{	}	
	void?run()	{	}	
	void?swim()	{	}	
	{
		System.out.println("beef");	
		System.out.println("person");	
		System.out.println("旺旺~~~~~");	
		System.out.println("quick");	
		System.out.println("會(huì)");	
	}	
????class?dog1?extends?Dog{public?dog1(){	super();??}?}????
????class?dog2?extends?Dog{public?dog2(){???super();??}?}?
????public?static?void?main(String?args[]){	
		Dog?dog=new?Dog();	
		System.out.println("姓名:"+dog.name);	
		System.out.println("年齡:"+dog.age);	
		System.out.println("顏色:"+dog.color);	
		System.out.println("體重:"+dog.weight);	
		System.out.println("性別:"+dog.sex);	
		dog.eat();	
		dog.look();	
		dog.yao();	
		dog.run();	
		dog.swim();
????}
}


1 回復(fù) 有任何疑惑可以回復(fù)我~

public class Test {

int age =5;

String name="樂樂";

String color="白色";

int weight =10;

String sex="female";

void eat() {

System.out.println("beef");

}

void look() {

System.out.println("person");

}

void yao() {

System.out.println("旺旺~~~~~");

}

void run() {

System.out.println("quick");

}

void swim() {

System.out.println("會(huì)");

}

public class dog1 extends Test {

public dog1(){ super(); ?

}

}

public class dog2 extends Test ? ?{

public dog2(){

super(); ? ? ??

} ? ?

}?

public static void main (String args[]) {

Test dog=new Test();

System.out.println("姓名:"+dog.name);

System.out.println("年齡:"+dog.age);

System.out.println("顏色:"+dog.color);

System.out.println("體重:"+dog.weight);

System.out.println("性別:"+dog.sex);

dog.eat(); ?

dog.look(); ?

dog.yao(); ?

dog.run(); ?

dog.swim();

}

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

不要在同一個(gè)java文件里寫好幾個(gè)類,public class一個(gè)類中只能出現(xiàn)一次。還有你括號(hào)丟了很多啊。主類就是main方法所在的類。你最后丟了個(gè)括號(hào),只剩下方法,當(dāng)然沒類了。

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

終結(jié)丶天涯

主類就是public修飾的class,并且里面有main方法。一個(gè)文件里,只能有一個(gè)主類。
2016-10-09 回復(fù) 有任何疑惑可以回復(fù)我~
#2

終結(jié)丶天涯 回復(fù) 終結(jié)丶天涯

汗,暈了,主類就是public修飾的class,一個(gè)文件里,只能有一個(gè)主類。完畢。
2016-10-09 回復(fù) 有任何疑惑可以回復(fù)我~
#3

cute倩影O_o 提問者

我剛開始是這樣想的,開頭的那個(gè)是父類,后面要加主類,就不知道怎么加了,謝謝
2016-10-09 回復(fù) 有任何疑惑可以回復(fù)我~

同一個(gè)文件里,只能有一個(gè)類為public,另定義的另兩個(gè)子類,不能加public。


public class Dog {
?? ?public static void main(String args[]) {
?? ??? ?Dog dog = new Dog();
?? ??? ?System.out.println("姓名:" + dog.name);
?? ??? ?System.out.println("年齡:" + dog.age);
?? ??? ?System.out.println("顏色:" + dog.color);
?? ??? ?System.out.println("體重:" + dog.weight);
?? ??? ?System.out.println("性別:" + dog.sex);
?? ??? ?dog.eat();
?? ??? ?dog.look();
?? ??? ?dog.yao();
?? ??? ?dog.run();
?? ??? ?dog.swim();
?? ?}

?? ?int age = 5;
?? ?String name = "樂樂";
?? ?String color = "白色";
?? ?int weight = 10;
?? ?String sex = "female";

?? ?void eat() {
?? ?}

?? ?void look() {
?? ?}

?? ?void yao() {
?? ?}

?? ?void run() {
?? ?}

?? ?void swim() {
?? ?}

?? ?{
?? ??? ?System.out.println("beef");
?? ??? ?System.out.println("person");
?? ??? ?System.out.println("旺旺~~~~~");
?? ??? ?System.out.println("quick");
?? ??? ?System.out.println("會(huì)");
?? ?}

?? ?class dog1 extends Dog {
?? ??? ?public dog1() {
?? ??? ??? ?super();
?? ??? ?}

?? ??? ?class dog2 extends Dog {
?? ??? ??? ?public dog2() {
?? ??? ??? ??? ?super();
?? ??? ??? ?}
?? ??? ?}
?? ?}
}

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

cute倩影O_o 提問者

謝謝你的回復(fù),可是子類怎么用完全覆蓋,部分覆蓋等其他方法去繼承父類啊
2016-10-09 回復(fù) 有任何疑惑可以回復(fù)我~

dog2 繼承還是用super()啊,你怎么用的this

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

主類怎么加進(jìn)去啊,代碼錯(cuò)了不會(huì)改

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)