+ 1

Doubt in code

i do ando excersise from any Challenge, but it show me error 6, do some show me where is the error? import static java.lang.System.out; public class Program { public static void main(String[] args) { int x = 10; try { system.out.print(7); if(x<0){ system.out.print(2); throw new Exception(); } } catch (Exception e){ system.out.print(4); } } }

9th Mar 2017, 7:10 PM
matufo
7 ответов
+ 11
Error at line 6: system - as said before you have to write System. After correction you will have the same error at lines 8 and 13. Same mistake, same way to correct it. After you corrected the errors the code will run at playground and you will get the output 7.
9th Mar 2017, 7:55 PM
Tashi N
Tashi N - avatar
+ 10
You have to write System instead of system. Btw, you don't need to import classes of the lang package. They are available without the import statement.
9th Mar 2017, 7:14 PM
Tashi N
Tashi N - avatar
+ 2
you have system.out.print. chance it to System.out.print Capital S
9th Mar 2017, 7:19 PM
LordHill
LordHill - avatar
+ 1
but i cant run this code, i try to run in console of sololearn and it show error 6 about any package is missing, do you can test code in your dispositive for see results, this code is match of any challenge and i want see the results, sry for.my bad english
9th Mar 2017, 7:22 PM
matufo
+ 1
haa jaja, ok ok, sry im noob, im trying to learn so its more hard because my english its not good, but i am undertand now, thanks for all, i will activate my acc for give us a hand up.
9th Mar 2017, 8:21 PM
matufo
0
why the answer is 7 why not 4 because always only the catch block will execute
10th Mar 2017, 9:47 AM
Vinay Kumar
Vinay Kumar - avatar
0
I mean try block only catches exceptions
10th Mar 2017, 9:47 AM
Vinay Kumar
Vinay Kumar - avatar