Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

why does it happen?

807600Sep 9 2007 — edited Sep 9 2007
i have two cases to analise tell me why so happens
void method()
{
Integer i ;
try{ i = new Integer(8);
}catch(Exception e){;}
System.out.println(i);
}
// generates an error that object might not be initialised now as far as i know i is object whose reference is outside try block than why does it get lost.
Interger i;
void method()
{
i = new integer(9);
}
void anotherMethod()
{
System.out.print(i);
}
// in the above case no such problem occurs
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2007
Added on Sep 9 2007
12 comments
107 views