0
Why is this code not valid?
public class Sololearn { int i = 7; public static void main(String[] args) { i++; } }
3 Answers
+ 1
to use i in main you have to make it static.
public class Sololearn {
static int i = 7;
public static void main(String[] args) {
i++;
}
}
0
or declare i locally within main or method.
public class Sololearn {
public static void main(String[] args) {
int i=7;
i++;
}
}
0
Nice!