请问为什么我这个类无法运行。。。老是说main的void类型不可用
- C# code
class VeryImportantException extends Exception{ public String toString(){ return "A very important exception!"; }}class HoHumException extends Exception { public String toString(){ return "A trivial exception"; }}public class Te{ void f() throws VeryImportantException{ throw new VeryImportantException(); } void dispose() throws HoHumException{ throw new HoHumException (); } public static void main void main(String[] args)throws Exception{ Te te = new Te(); try{ te.f(); }finally{ te.dispose(); } }}直接上代码了 - - main下面老是有波浪线
[解决办法]
改成下面这样试试
- Java code
class VeryImportantException extends Exception{ public String toString(){ return "A very important exception!"; }}class HoHumException extends Exception { public String toString(){ return "A trivial exception"; }}public class Te{ void f() throws VeryImportantException{ throw new VeryImportantException(); } void dispose() throws HoHumException{ throw new HoHumException (); } public static void main (String[] args)throws Exception{ Te te = new Te(); try{ te.f(); }finally{ te.dispose(); } }}
[解决办法]
明显的代码错误
- Java code
public static void main void main(String[] args)
[解决办法]
- Java code
public static void main void main(String[] args)
[解决办法]
public static void main void main(String[] args)throws Exception
两个void main 啊
[解决办法]
这个貌似在考验大家的仔细度,多了一个void main ,楼主写代码要仔细点哦。
[解决办法]
[解决办法]
汗......
[解决办法]
汗。。楼主是在搞啥。。。
[解决办法]
[解决办法]
要仔细~~~~