Community
Participate
Working Groups
Hi, I have this snippet: public static void main(String[] args) { int a, b = 0; System.out.println(a); System.out.println(b); } and whn compiling it has two errors (the text from the summary). The same thing but: public static void main(String[] args) { int a = 0; int b = 0; System.out.println(a); System.out.println(b); } compiles perfectly. I understand this is a bug because both snippets are the same. Right?
No, the multi variable declaration is only initializing 'b'. In order to initialize both, you should have written: int a = 0, b = 0;
Ok. Sorry, then it was a lack of knowledge in my part.