+ 1

Why is error generating in this code?

class mo { public static void main(String ab[]) { int a=Integer.parseInt(ab[0]); int b=Integer.parseInt(ab[1]); int c=a+b; System.out.println(c); } }

7th Jun 2017, 10:12 AM
Shubham Agarwal
Shubham Agarwal - avatar
6 Respostas
0
if you run this program in ide you don't have any parameters in main class and there is no 0 or 1 element
7th Jun 2017, 10:15 AM
denis
denis - avatar
0
and you need one more }
7th Jun 2017, 10:16 AM
denis
denis - avatar
0
Yup one more}
7th Jun 2017, 10:17 AM
Shubham Agarwal
Shubham Agarwal - avatar
0
But this code is running properly in other systems
7th Jun 2017, 10:17 AM
Shubham Agarwal
Shubham Agarwal - avatar
0
you need to start this code on command line as follows java po 20 12
7th Jun 2017, 12:06 PM
Milind
Milind - avatar
0
Thanks
7th Jun 2017, 12:18 PM
Shubham Agarwal
Shubham Agarwal - avatar