I started programming in Eclipse. I have an error in the code I wrote (see the comments in the code):
import javax.swing.*;
public class SumaConJOptionPane {
public static void main(String[] args) {
String usuario, aux1, aux2;
int a, b;
// Se solicita nombre de usuario
usuario = JOptionPane.showInputDialog("Ingrese nombre de usuario");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// muestra el nombre y le indica al usario que se va a hacer una suma
JOptionPane.showMessageDialog(null, "Muy bien " + usuario + "! V amos a hacer una suma");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// A continuacion solicita el ingreso del primer numero
aux1 = JOptionPane.showInputDialog("Ingresa un numero: ");
a = Integer.parseInt(aux1); // En esta linea lo que hace es convertir al 'string' del JOptionPane en un 'int'
// con el metodo Integer.parseInt(aqui va la variable del JOptionPane)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Solicita el segundo numero
aux2 = JOptionPane.showInputDialog("Ingresa el otro numero: ");
b = Integer.parseInt(aux2); // En esta linea lo que hace es convertir al 'string' del JOptionPane en un 'int'
// con el metodo Integer.parseInt(aqui va la variable del JOptionPane
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Finalmente nombra al usuario, muestra los numeros ingresados, y el resultado de la suma entre dichos numeros
JOptionPane.showMessageDialog(null, "Bien " + usuario + "! " + a + " + " + b + " es igual a " + (a + b) + "");
}
}
What happens is ... it works, but anyway the red underline appears in the JOptionPane
indicating an error, but it works anyway!
Can anyone tell me what it could be? I do not know if it will be syntax or the JRE or JDK, I already reviewed them and they are all in the same version.