Bookmark Topic Watch Topic
  • New Topic

A simple question on Local Variables  RSS feed

 
Ianz Somald
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
Why

int a=4,b;
if(a==4)
b=5;
System.out.print(b);

Gives Compile Time Error

but

int a=4,b;
if(a==4)
b=5;

else
b=6;
System.out.print(b);

does not. Please explain the reason.

Thanks
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Report post to moderator
Gives Compile Time Error

Please copy the full text of the compiler's error message and paste it here so we can see what you are asking about.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Report post to moderator
Don't ask the same question twice. I am locking this thread.
Please continue all discussion here.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!