java中未报告的异常 ;必须对其扑捉或声明以便抛出异常
classNumberRangeExceptionextendsException{publicNumberRangeException(Stringmsg){super...
class NumberRangeException extends Exception
{
public NumberRangeException(String msg)
{
super(msg);
}
}
public class Time
{
private String hour;
private String minute;
private String second;
private static DecimalFormat twoDigits = new DecimalFormat( "00" );
public void setSecond( String s )throws NumberRangeException
{
try
{
if(Integer.parseInt(s)>100)
{
NumberRangeException e=new NumberRangeException("超范围了");
throw e;
}
second = s;
}
catch(NumberRangeException e)
{
System.out.println(e.toString());
}
}
}
部分代码省略,求大神支援!!! 展开
{
public NumberRangeException(String msg)
{
super(msg);
}
}
public class Time
{
private String hour;
private String minute;
private String second;
private static DecimalFormat twoDigits = new DecimalFormat( "00" );
public void setSecond( String s )throws NumberRangeException
{
try
{
if(Integer.parseInt(s)>100)
{
NumberRangeException e=new NumberRangeException("超范围了");
throw e;
}
second = s;
}
catch(NumberRangeException e)
{
System.out.println(e.toString());
}
}
}
部分代码省略,求大神支援!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询