Ints Inicialization and Throw statemtn

  • Thread starter Thread starter Rafael Veronezi
  • Start date Start date
R

Rafael Veronezi

I have two simple questions...
One is about, how to verifiy if an integer variable has been initialized?
I mean, i have a private field declared as int, and a method that access
this field, and needs to test it to verify if it has been previously
initialized...
Actually i'm testing if it's value is equals to zero... Don't know is that
the way, I know I can't test it against null...

The other simple question is...
I'm using a throw statement in one of my methods...
When the method reachs the throw, I know it halt the execution of the
method, but, if the calling function treats this exception with a
try...catch, is the method being executed still halts, or continue it's
procession at the point where the exception was throw, after the successful
treatment on the try...catch?

Thanks,
Rafa
 
Rafael,
One is about, how to verifiy if an integer variable has been initialized?

ints and other value types doesn't really have an uninitialized state
(such as null for reference types).

I mean, i have a private field declared as int, and a method that access
this field, and needs to test it to verify if it has been previously
initialized...

Can't you just assign it whatever initial value you want at the point
of declaration or in a constructor? If you don't, its initial value
will be zero.

The other simple question is...
I'm using a throw statement in one of my methods...
When the method reachs the throw, I know it halt the execution of the
method, but, if the calling function treats this exception with a
try...catch, is the method being executed still halts, or continue it's
procession at the point where the exception was throw, after the successful
treatment on the try...catch?

The execution continues after the try..catch block (possibly in the
finally block if you have one) of the calling method.



Mattias
 
Back
Top