You tried to input data from JOptionPane window, convert it to integer....But you pressed cancel instead of OK button... So JOptionPane returns "".And your program convert it...That's my guess..