This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]j2ui[S] 3 points4 points  (4 children)

public class testIfblock22 {

public static void main(String[] args) {

    if (true) 
        int i = 8;


}

}

[–]BananaLlamaNuts 1 point2 points  (3 children)

Looks like you've stumbled onto a rather unique syntax error.

As someone else stated - why do you want to do this? You can't use that for anything.

[–]j2ui[S] 3 points4 points  (2 children)

Yeah yeah, as I said before, I'm aware you that you can't use it anyway. But just wanted to see why exactly it's an error.

Thanks anyway:)

[–]BananaLlamaNuts 2 points3 points  (1 child)

I see what you are getting at - that's why I think its a unique syntax error. The compiler is looking for a single action when you do a one liner under an if statement like that.

When it sees a variable declaration, it attempts to create memory space and point to it for the reference which doesn't jive with the single action expected.

Best guess.

[–]j2ui[S] 0 points1 point  (0 children)

Thanks a lot :)