java中输入负数,怎样抛出异常
有那位大侠路过,感激不尽
------解决方案--------------------if(f<0){
 throw new Exception("输入不能为负数!")
}
------解决方案--------------------public void test(int i) throws Exception{
    if(i < 0){
           throw new Exception("负数");
    }
}
main里面调用
  try {
    //调用test(-1);
 } catch(Exception e) {
 //做处理就可以了
 }
------解决方案--------------------小于0作出判断就行了,2、3L的都行