+ 3
Whats wrong in my code?
public class practice { public static void main(String[] args) { double myArray[] = {2.5,4.1,18.1,22.3}; double sum = 0.0; for(int x = 0; x < 4;x++); { sum += myArray[x]; } } System.out.println(sum); } The code give me an error. /practice.java:12: error: <identifier> expected System.out.println(sum); /practice.java:9: error: cannot find symbol sum += myArray[x]; plz explain the whole code.
4 Answers
+ 3
move the print statement inside main()
+ 1
Another error .
/practice.java:9: error: cannot find symbol
sum += myArray[x];
+ 1
behind the normal braces of the for loop, remove that semicolon:)
+ 1
Thank u guyz...