+ 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); }
2 Réponses
+ 4
Please review the section on arrays in the tutorial
https://www.sololearn.com/Course/Java/?ref=app
+ 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
}
}