-1
不能找出爲什麼我不斷收到此錯誤。我試圖編寫一個程序,將添加一個2位數字的總和。錯誤:無法找到符號input.nextdouble
SplitNum.java:9: error: cannot find symbol
double digit = input.nextdouble();
^
symbol: method nextdouble()
location: variable input of type Scanner
1 error
代碼:
import java.util.Scanner;
public class SplitNum
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter 2 digit number");
double digit = input.nextdouble();
double tens = digit/10.0;
double ones = digit % 10.0;
double sum = tens+ones;
System.out.println(sum);
}//end main
}//end class
這是'input.nextDouble()' – Reimeus
awhhh非常感謝它 – user3250337
同時還要注意,Java和Javascript是完全不同的語言。 –