Solved java if statement errors

July 10, 2012 at 17:54:08
Specs: Windows 7
1 public class Program {
2 public static void main(String args[]) {
3 int a = 5;
4 if ( int a > 0 ) {
5 int a = 7;
6 }
7 }
8 }

my IDE says for line 4:
.class expected
illegal start of expression
; expected

and for line 8:
class, interface, or enum expected.

my IDE has never said this before, what is wrong with my code?


See More: java if statement errors

Report •

#1
July 14, 2012 at 05:11:49
✔ Best Answer
For starters, remove the "int"s in lines 4 and 5. You only specify the type when you first declare a variable, not every time you use it.

Report •
Related Solutions


Ask Question