Hy … I have the following code :
try { Nrtrde record = new Nrtrde(); }
catch (Exception e) {
System.out.println(" ERROR\n");
e.printStackTrace(); }
finally { Nrtrde record = new Nrtrde(); System.out.println(" OK\n"); }
record.setSpecificationVersionNumber(specificationVersionNo);
and when compiling i get the following error :
NRTRDE\ENCODER.java:28: error: cannot find symbol
record.setSpecificationVersionNumber(specificationVersionNo);
^
symbol: variable record
location: class ENCODER
1 error
It seems I cannot create an object insinde a try {} and use it outside try {} ..
Why ?
Thank you
You have to declare it outside the block, but you can initialize it inside the block:
In Java,
{}are block delimiters. Nothing is visible outside the block it is defined in. (Class members are an exception to this rule if the visibility allows it).