我得到我的代碼以下錯誤: -Missing return語句 -Cannto在第二種方法缺少return語句
這裏找到符號是我的代碼:
import java.io.*;
import javax.swing.JOptionPane;
public class Converter {
public static void main(String[] args) throws Exception{
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String unit = JOptionPane.showInputDialog("Enter unit F or C: ");
String temp1 = JOptionPane.showInputDialog("Enter the Temperature: ");
double temp = Double.valueOf(temp1).doubleValue();
}
public static double convertTemp(){
if((unit.equals("F"))||(unit.equals("f"))){
double c= (temp - 32)/1.8;
JOptionPane.showMessageDialog(null,c+" Celsius"));
}
else if((unit.equals("C"))||(unit.equals("c"))){
double f=((9.0/5.0) * temp) + 32.0;
JOptionPane.showMessageDialog(null,f+" Fahrenheit");
}
}
}
什麼是不清楚的錯誤,告訴你,你沒有return語句。 ..當你沒有回報聲明? – 2012-03-19 15:01:26
你[已經有一個問題打開](http://stackoverflow.com/questions/9771136/method-calling-error)。 – Jesper 2012-03-19 15:02:07