What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory?
import java.io.*;
public class Test
{
public static void main(String argv[])
{
Test t = new Test();
System.out.println(t.myMethod());
}
public int myMethod()
{
try
{
FileInputStream dis = new FileInputStream("Hello.txt");
}
catch (FileNotFoundException fne)
{
System.out.println("No such file found");
return -1;
}
catch(IOException ioe)
{
}
finally
{
System.out.println("Doing finally");
}
return 0;
}
}
结果为什么会是:No such file found, Doing finally, -1。。
这个-1是怎么回事?
[此贴子已经被作者于2006-9-6 14:51:42编辑过]