Please need your correction | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please need your correction

public class Program { public static void main(String[] args) { int s=0 for(int d:x) s+=d; System .out .println ("s%d\n,"s) } }

27th Jan 2018, 10:09 PM
Abubakar Usman Dabban
1 Answer
+ 3
missing ';' in line 4, 7 misding '{' and '}', they are not necessary when you iterate over a single line code. Depending on your goal you need to add them after your 'For' loop header. And here are the differences in your options. Either after line 6 or line 7. after line 6 results in one output. After line 7 results in multiple outputs. And you iterate throuh an uninitialised object x...
27th Jan 2018, 10:24 PM
Andreas K
Andreas K - avatar