class CalcThread extends Thread{private double result;public void run(){ result=calculate();}public double getResult(){return result;}public double calculate() {}}class ShowJoin{public static void main (String [] args){CalcThread calc=new CalcThread(
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 16:19:32
class CalcThread extends Thread{private double result;public void run(){ result=calculate();}public double getResult(){return result;}public double calculate() {}}class ShowJoin{public static void main (String [] args){CalcThread calc=new CalcThread(
class CalcThread extends Thread{
private double result;
public void run(){
result=calculate();
}
public double getResult(){
return result;
}
public double calculate() {
}
}
class ShowJoin{
public static void main (String [] args){
CalcThread calc=new CalcThread();
calc.start();
try{
calc.join();
System.out.println("result is"+calc.get.Result());
}
catch (InterruptedException e){
System.out.println("no answer :interrupted");
}
}
}
第九行提示错误This method must return a result of type double
第18行提示calc.get cannot be resolved or is not a field
class CalcThread extends Thread{private double result;public void run(){ result=calculate();}public double getResult(){return result;}public double calculate() {}}class ShowJoin{public static void main (String [] args){CalcThread calc=new CalcThread(
public double calculate() {
//这个方法必须return一个double的值
return true;
}
System.out.println("result is"+calc.get().Result());
//System.out.println("result is"+calc.get.Result());
//get后面少了括号.