input exception error in Java -
i keep getting exception error. simple code. why getting exception error?
class thirdprogram { public static void main(string[] args) { system.out.println("hello out there."); system.out.println("i add 2 numbers you."); system.out.println("enter 2 whole numbers on line."); int n1, n2; scanner keyboard = new scanner(system.in); n1 = keyboard.nextint(); n2 = keyboard.nextint(); system.out.println("the sum of 2 numbers is"); system.out.println(n1 + n2); } }
when use:
do following:
step 1
make sure select java on left.
step 2
enter code:
import java.util.scanner; class thirdprogram { public static void main(string[] args) { system.out.println("hello out there."); system.out.println("i add 2 numbers you."); system.out.println("enter 2 whole numbers on line."); int n1, n2; scanner keyboard = new scanner(system.in); n1 = keyboard.nextint(); n2 = keyboard.nextint(); system.out.println("the sum of 2 numbers is"); system.out.println(n1 + n2); } }
step 3
before hit submit button, click click here enter input (stdin) or additional note
. once click it, 2 boxes appear. in first box ( enter input (stdin)
), enter:
5 7
make sure press enter after 7.
step 4
then hit submit. results load @ bottom.
note:
you should download , use ide instead (like jgrasp or eclipse). ides come compilers , allow enter input in after run program console.
Comments
Post a Comment