修理我PLZ。我得到多個錯誤消息 「變量airSpeed_km可能尚未初始化」 「變寬度可能尚未初始化」 「可變長度可能尚未初始化」有調用方法的麻煩。我錯過了什麼?
import java.util.Scanner;
public class V4_________1{
public static void main (String args[])
{
Scanner keyboard = new Scanner(System.in);
double KNOTS_TO_KMPHR;
double airSpeed_km;
double airSpeed_knots;
double width;
double length;
***// need to do something in the main but not sure what exactly***
airSpeed_knots = keyboard.nextDouble();
System.out.println("what is your current airspeed in knots?");
System.out.println("your current airspeed in km is: " + airSpeed_km + "your holding pattern width is: " + width + "your holding patter length is: " + length);
}
public static double getAirSpeed(double airSpeed_knots, double KNOTS_TO_KMPHR, double airSpeed_km)
{
KNOTS_TO_KMPHR = 1.852;
airSpeed_km = airSpeed_knots * KNOTS_TO_KMPHR ;
return airSpeed_km;
}
public static double calcPatternWidth(double width, double airSpeed_km)
{
width = (airSpeed_km)/(60 * Math.PI) * 2;
return width;
}
public static double calcPatternLength(double airSpeed_km, double length)
{
length = (airSpeed_km)/(60 * Math.PI) * 2 + ((airSpeed_km)/60);
return length;
}
}
的可能重複[變量可能尚未初始化錯誤](http://stackoverflow.com/問題/ 2448843 /可變可能-不具備的,被初始化錯誤) – Boann 2014-10-14 16:04:57