Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/09/2015, 22:18
ronynne_jenny14
 
Fecha de Ingreso: septiembre-2015
Mensajes: 1
Antigüedad: 8 años, 8 meses
Puntos: 0
Pregunta Exception in thread "main" java.lang.NumberFormatException: For input string: ""

Buenas, este es mi codigo, sé que es una programa sencilla. Quisiera saber cuál es el error que cometo; dsps que introduzco 2 números. Me sale esto:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at Suma.main(Suma.java:25)

import java.io.*;

class Su{
private int n1,n2;
public void asignar (int a, int b){
n1=a;
n2=b;
}

public int calcular()
{
int res;
res=n1+n2;
return(res);
}
}

class Suma{
public static void main (String[] arg) throws IOException{
BufferedReader r1 = new BufferedReader (new InputStreamReader(System.in));
int a,b,tot;
System.out.println("Introduzca 2 numeros");
a = Integer.parseInt(r1.readLine());
b = Integer.parseInt(r1.readLine());
Sum obj_su = new Sum();

obj_su.asignar(a,b);
tot=obj_su.calcular();
System.out.println("La distancia es"+tot);

}
}