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

為了賬號安全,請及時綁定郵箱和手機立即綁定

請問怎么會提示錯誤呢?

https://img1.sycdn.imooc.com//5cbed6b30001565f06260206.jpg

https://img1.sycdn.imooc.com//5cbed6b400018e6007580094.jpg

package com.xuanxuan;


public class Actor extends Thread {

public void run() {

System.out.println(getName()+"是一個演員");

int count=0;

boolean keepRuning=true;

while(keepRuning) {

System.out.println(getName()+"登臺演出"+(++count));

if(count==100) {

keepRuning=false;

}

if(count%10==0) {

try {

Thread.sleep(2000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

System.out.println(getName()+"演出結(jié)束了");

}

class Actress implements Runnable{

public void run() {

System.out.println(Thread.currentThread().getName()+"是一個演員");

int count=0;

boolean keepRuning=true;

while(keepRuning) {

System.out.println(Thread.currentThread().getName()+"登臺演出"+(++count));

if(count==100) {

keepRuning=false;

}

if(count%10==0) {

try {

Thread.sleep(2000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

System.out.println(Thread.currentThread().getName()+"演出結(jié)束了");

}

}


public static void main(String[] args) {

// TODO Auto-generated method stub

Thread actor=new Actor();

actor.setName("先生");

Thread actressThread=new Thread(new Actress(),"女士");

actor.start();

actressThread.start();

}


}


正在回答

3 回答

class Actress implements Runnable{

public void run() {

System.out.println(Thread.currentThread().getName()+"是一個演員");

int count=0;

boolean keepRuning=true;

while(keepRuning) {

System.out.println(Thread.currentThread().getName()+"登臺演出"+(++count));

if(count==100) {

keepRuning=false;

}

if(count%10==0) {

try {

Thread.sleep(2000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

System.out.println(Thread.currentThread().getName()+"演出結(jié)束了");

}

}

這個class Actress叫做內(nèi)部類,他和public class Actor是同級的,所以Actress應(yīng)該放在Actor的大括號的外面。

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

tiger愛小狄

有一句話我說的不對 class Actress不是內(nèi)部類
2019-07-05 回復(fù) 有任何疑惑可以回復(fù)我~

Actress類放外面。不是放在Actor里面的

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

在你的Actress類前面加個static

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

劍雨319

原理應(yīng)該是靜態(tài)方法會先加載?而你的內(nèi)部類Actress不是靜態(tài)方法還不存在?大概就是這個意思吧
2019-04-24 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

請問怎么會提示錯誤呢?

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

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

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