I have a problem with my code
nama=txtNama.getText().trim();
int nim =Integer.parseInt(txtNIM.getText());
alamat=txtAlamat.getText().trim();
int telp =Integer.parseInt(txtTelp.getText());
In the code Integer
int nim =Integer.parseInt(txtNIM.getText());
int telp =Integer.parseInt(txtTelp.getText());
I only can input 10 number, if I have input more than 10 number it will be an error
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "1111111111111"
Thanks for your attention and help.
An Integer in java is 32 bits long, it can only hold values from [-2147483648, 2147483647].
Use a long
long nim = Long.parseLong(txtNIM.getText());
long telp = Long.parseLong(txtTelp.getText());
A long is 64 bits, it can hold values from [-9223372036854775808, 9223372036854775807]
If you must go bigger, you can use BigInteger class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With