0
Why is this code not working?
Iâm trying to total the primes and print the result. It keeps throwing an error where I placed the ^ I donât understand why. public class Program { public static void main(String[] args) { int[ ] primes = {2, 3, 5, 7}; int total=0; for (int x: primes) { total+=x;} System.out.printIn(total); ^ } }
6 RĂ©ponses
+ 2
System.out.println(total);
Edit: In println that is a small "L" and not capital "i".
+ 7
public class Program {
public static void main(String[] args) {
int[ ] primes = {2, 3, 5, 7};
int total=0;
for (int x: primes) {
total+=x;}
System.out.println(total);
}
}
That's println not printIn you have used in instead of ln
+ 6
Quinten L is capital in println
no problem Java is good to start just keep practising
0
Avinesh: Im confused, i have total inside printIn.
Gawen: im not seeing any difference in the two you typed?
sorry guys, first day learning this!
0
the âiâ is capitalized in my code. isnt it?
0
oh its supposed to be an L?