Originally posted by Gong James:
<pre>public class AllFinals
{
{
final Vector v;
v=new Vector();
}
public AllFinals()
{
}
public void someMethod()
{
System.out.println(v.isEmpty());
}
}
</pre>
.........................
But i think the block
{
final Vector v;
v=new Vector();
}
is execute once the class AllFinals is loaded,which is seems like the memebre field,as a result,the compile give me error as the ANS B said,but when the block code is execute?
Hi
this is not static block so it will be executed when an instance will be created.
but point is that " Vector v " is local variable here not a instance variable , generally we assume that after class name variable are instance variable . This is good question..... which says READ Que. CAREFULLY and MARK the blocks.
------------------
Regards
Ravish