大神求助 java异常问题

大神帮帮我 我这个主函数总是错误 题目是 定义一个异常类 输入一串数字 如果超过6个则报错!图片

main方法不对,(String[] args)
少一个大括号
这是你报错的原因,具体代码还没看

class numException extends Exception {
private String reason;
numException(String reason){
this.reason=reason;
}
String out(){
return(reason);
}

class test{
test(String a) throws numException{
if(a.length()!=6)
throw new numException("邮编必须是6位!");
}
}

class fhgh{
public static void main(String args[]) {
try {
new test("150815119");
}
catch(numException e)
{
System.out.println(e.out());
}
}
}

class numException extends Exception {
private String reason;
numException(String reason){
this.reason=reason;
}
String out(){
return(reason);
}

class test{
test(String a) throws numException{
if(a.length()!=6)
throw new numException("邮编必须是6位!");
}
}

class fhgh{
public static void main(String args[]) {
try {
new test("150815119");
}
catch(numException e)
{
System.out.println(e.out());
}
}
}

main方法,只能放在public 的 class内吧

问题被我找到啦 我定义的第一个类少一个括好 图片说明粗心了