Basic Array creation but failing | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Basic Array creation but failing

I am trying to do a array problem but I seem to get a error at the "for" , "5", and "i++" Any ideas on what I'm doing wrong? package sample; public class ArrayQuiz { int result = 0; for(int i =0; i<5; i++){ if(i==3){ result += 10; }else{ result += i; } } System.out.println(result); }

1st Nov 2018, 8:40 PM
Vell Jackson
Vell Jackson - avatar
2 ответов
+ 4
Please review the section on arrays in the tutorial https://www.sololearn.com/Course/Java/?ref=app
1st Nov 2018, 9:21 PM
BroFar
BroFar - avatar
+ 4
Vell Jackson Well, the problem is not on for loop but its more to base... Your code have to be putted inside one method (in this case main) into class else java cannot compile it. This is the model: public class MyClass{ public static void main(String[] args){ // Your code here } }
1st Nov 2018, 10:57 PM
KrOW
KrOW - avatar