麻烦看看哪里有问题

麻烦看看哪里有问题

package com.imooc.test;


class weather {

private int temperature;

private int humidity;

boolean flage = false;


@Override

public String toString() {

return "温度:" + this.temperature + "湿度" + this.humidity;

}


public int getTemperature() {

return temperature;

}


public void setTemperature() {

this.temperature = (int) (Math.random() * 40);

}


public int getHumidity() {

return humidity;

}


public void setHumidity() {

this.humidity = (int) (Math.random() * 100);

}


public synchronized void setter() {

if (flage) {

try {

wait();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

this.setHumidity();

this.setTemperature();

System.out.println("生成的数据为" + this.toString());

flage = true;

notifyAll();


}


public synchronized void getter() {

if (!flage) {

try {

wait();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


this.setHumidity();

this.setTemperature();

System.out.println("得到的数据为" + this.toString());

flage = false;

notifyAll();


}


class Seweather implements Runnable {

weather wea;


public Seweather(weather wea) {

this.wea = wea;

}


@Override

public void run() {

// TODO Auto-generated method stub

for (int i = 0; i < 100; i++) {

wea.setter();

try {

Thread.sleep(5000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}


class Geweather implements Runnable {

weather wea;


public Geweather(weather wea) {

this.wea = wea;

}


@Override

public void run() {

// TODO Auto-generated method stub

for (int i = 0; i < 100; i++) {

wea.getter();

try {

Thread.sleep(100);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}


}


public class Paractice5_3 {


public static void  main(String[] args) {

// TODO Auto-generated method stub

weather wea = new weather();

new Thread(new Seweather(wea)).start();

new Thread(new Geweather(wea)).start();

}


}

错误: 找不到或无法加载主类 com.imooc.test.Paractice5_3

原因: java.lang.ClassNotFoundException: com.imooc.test.Paractice5_3


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
吃吃吃鱼的猫 2019-05-23 18:11:31

同学运行其他的类没有问题吗?

那说明环境变量没有问题。问一下同学所贴出的类是否在同一个包下呢?

建议同学先复制下测试类中的代码,重新创建测试类,再将代码复制进去,测试是否能够成功。

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

吃吃吃鱼的猫 2019-05-23 17:50:43

同学你好,我这里运行你的代码没有报错哦~

检查一下java环境变量是否配置正确,然后用记事本敲一下编译后试试看~

同时,根据类名规范,类名首字母应该大写哦~

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

  • 提问者 慕神9477737 #1
    怎么检查环境变量是否正确啊老师?我以前不是搞过了吗?我运行我电脑里面其他的程序也没有报这个错。能贴下详细步骤吗?谢谢
    2019-05-23 17:57:58
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师