我试图运行下面的代码处理,但我得到错误,请澄清我的疑问异常在Java
import java.util.*;
class Except
{ public class AlfaException extends Exception{}
public static void main(String[] args)
{
int b;
Scanner s=new Scanner(System.in);
try
{
b=s.nextInt();
}
catch(InputMismatchException ex)
{
try
{
if(('b'> 67)&&('b'<83)){}
}
catch(AlfaException e){
throw new AlfaException("hello");
}
System.out.println("error found");
}
}
}
Except.java:20: non-static variable this cannot be referenced from a static cont
ext
throw new AlfaException("hello");
^
1错误
我不知道为什么我不能编辑甚至因重新打这个问题 –
@eng有人用低于2000的声誉已经编辑了该问题,并且编辑尚未获得具有较高声誉的用户的批准。 –
或者,您可以按如下所示抛出异常:'new Except()。new AlphaException();'。 –