A Class sumNumber package, a class request contains two parameters of type String indicates the type of double its value summing method, NumberFormatException is thrown if an incorrect data transfer when passing arguments exception handling

Software NetBeans IDE 7.0.1, need to write the main class alone.

A Class sumNumber package, a class request contains two parameters of type String indicates the type of double its value summing method, NumberFormatException is thrown if an incorrect data transfer when passing arguments exception handling, suggesting redelivery parameter. Packaging executes the main class.

Main categories:

 SumNumber s=new SumNumber();
       s.toCatch("aa","22222222");

SumNumber categories:

public class SumNumber {
               
        double sum=0;
        public void toCatch(String a,String b){
            
            try{
              
               double c=Double.parseDouble(a);
               double d=Double.parseDouble(b);
               double sum=c+d;
               System.out.println(sum);
            }catch(NumberFormatException e){
                
            }
             
            System.out.println("接下来继续执行程序........");
        }
}

Published 24 original articles · won praise 28 · views 2265

Guess you like

Origin blog.csdn.net/weixin_46292455/article/details/104973261