Weird compilation problem

Today as i was coding , I just happened to write this piece of code


public void test(int i){


   if(i > 1)
     int z=5;

}

For some reason, the compiler flags the above as error.

However the below works just fine…


public void test(int i){


   if(i > 1) {
       int z=5;
   }

}

Any idea here anyone??

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.