1
With this code I get the error:
error: class expected
import javax.swing.JOptionPane;
public class MenorIdade {
public static void main(String[] args) {
String[] nomes = new String[5];
int [] idades = new int[5];
int maisJovem = 0;
for (int i = 0; i <= 4; i++) {
nomes[i] = JOptionPane.showInputDialog("Informe o nome");
idades[i] = int.parseInt(JOptionByte.showInputDialog("Informe a idade"));
if (idades[i] < idades[maisJovem]) {
maisJovem = i;
}
}
JOptionPane.showMessageDialog(null, nomes[maisJovem] + " é mais jovem e tem " + idades[maisJovem] + " anos.");
}
}
It would be a valid way, @Maria. At first I didn’t understand why the
String showInputDialog;
intermediate, but I ended up seeing. But, even functional, is not necessary, since it can do theparse
directly.– Gustavo Cinque
I’ll edit my answer so Camuratti can look at the two forms, okay?
– Gustavo Cinque
@Gustavocinque, quiet do yes...!
– Maria
@Gustavocinque in relation to
parse
, in my opinion this code needs to be improved, because there is no criticism in the contents that can be typed...– Maria
Um, it’s just that I’ve always used the parse on input, hehe. Speed on writing and reading, for me.
– Gustavo Cinque
So at this point I disagree and if the guy type letter instead of number? not even a block
try
catch
he put understand– Maria
You’re right. If it did, it would make a beautiful
NumberFormat
.– Gustavo Cinque
Thanks for the help, @Maria!!
– Camuratti