-3

how can i solve it`NumberFormatException:

public class Maria {

public static void main(String[] args) {
    String datoLeido="";
   String datoAux=null;
   int datoConvertido;
   Scanner teclado=new Scanner(System.in);
   
          
        System.out.println(" Favor de ingresar el nombre");
        datoLeido=teclado.nextLine();
                         
            if(datoLeido.length()>2)
            datoAux="Hola"+datoLeido;
            int Longuitud=datoAux.length();
            datoConvertido=Integer.parseInt(datoAux);
            System.out.println(datoAux);
            
        
    }        
        
}

my teacher asked me to solve two errors with exceptions, how can I do it.. this error appears: Exception in thread "main" java.lang.NumberFormatException: For input string: "Holaangel" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at maria.Maria.main(Maria.java:29)

  • 1
    Which exceptions? Please provide more information. Also JavaScript is not related to Java (in question tags). – Jax-p May 19 '22 at 14:39
  • I take it,when you compile the code, you have some error? Or do you get an exception when you do something specific with the program when it runs? Please, be specific about what happens and when it happens. Also, yeah, fix the tags, javascript has nothing to do with it. – Ilya May 19 '22 at 14:43
  • 1
    [Open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/q/6166/263213) – Alicia Sykes May 19 '22 at 14:47
  • You have error at line 29. The error says that you apply function to some data on line 29, and this data type is not supported by that function. You need to do something about it. – Ilya May 19 '22 at 14:53

1 Answers1

0

You can pipe multiple exception with help of | in catch.

" catch(IOException | SQLException ex) "