This discussion is archived
1 Reply Latest reply: Aug 18, 2012 7:51 PM by EJP RSS

Code is not compiling  is this java defect ?

956539 Newbie
Currently Being Moderated
below java code is not compiling showing error message.
if(true)
Object obj=new Object(); //here I have tried to test with other class as well but result is same code is showing error message.

while if add curly bracket to if condition like below code working fine.


if(true){
Object obj=new Object();
}

can anybody please explain the above difference.

Edited by: user12152025 on Aug 18, 2012 10:20 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points