所以基本上我正在做一個java教程,但爲了跟着我需要做一個類文件。一切都已經給了我,但它給了我一個錯誤。錯誤是:刪除else語句或沿着這些行的東西。但是,當我刪除它告訴我把另一個else語句在那裏。 代碼是:這是一個與日食問題或有問題的代碼?刪除else語句,但需要其他語句
import java.io.*;
import java.text.*;
public class In
{
static InputStreamReader r=new InputStreamReader(System.in);
static BufferedReader br=new BufferedReader(r);
// Read a String from the standard system input
public static String getString()
{
try
{
return br.readLine();
}
catch(Exception e)
{
return "";
}
}
// Read a number as a String from the standard system input
// and return the number
public static Number getNumber()
{
String numberString = getString();
try
{
numberString = numberString.trim().toUpperCase();
return NumberFormat.getInstance().parse(numberString);
}
catch(Exception e)
{
// if any exception occurs, just return zero
return new Integer(0);
}
}
// Read an int from the standard system input
public static int getInt()
{
return getNumber().intValue();
}
// Read a long from the standard system input
public static long getLong()
{
return getNumber().longValue();
}
// Read a float from the standard system input
public static float getFloat()
{
return getNumber().floatValue();
}
// Read a double from the standard system input
public static double getDouble()
{
return getNumber().doubleValue();
}
// Read a char from the standard system input
public static char getChar()
{
String s = getString();
if (s.length() >= 1)
return s.charAt(0);
else
return ’\n’;
}
}
您也有縮進問題。首先考慮關注該部分(這會讓你看到/防止其他可能的問題)。 – Pshemo 2014-10-10 17:24:10
很確定這是代碼問題。 – 2014-10-10 17:24:38
@Pshemo是什麼導致問題?因爲這只是從教科書中複製並粘貼的。...... – Liste1134 2014-10-10 17:25:04