Top
cuilonggang(白金) ( ) 信誉:
bad class file: .\Exception.java
很有可能的原因:
你当前目录下有个可能你测试编的Exception.java文件,编译时JDK使用了这个文件,而没有使用系统的Exception.java(系统的Exception类)
-----------------------------------------------------------------------------------
感谢大家,错误原因找出:真如 白金 所说,我的文件夹中的确有个名为Exception.java的JAVA文件,删除这个文件后,一切正常!
源程序是这样的
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class SSqrt
{
public static void main(String[] args)
{
long i = 0 ;
System.out.println("输入一个实55数 :");
try
{
BufferedReader reader = new BufferedReader( new InputStr
eamReader(System.in));
i =Long.parseLong( reader.readLine() );
}catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println(i + " 的平方根 = "+Math.Sqrt(i));
}
}
编译后出现的错误:
SSqrt.java:13: cannot access Exception
bad class file: .\Exception.java
file does not contain class Exception
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
}catch(Exception e)
^
1 error