here why I am getting compile time error as AllFinals.java:7: Identifier expected. v=new Vector(); Although I am changing the refrence of the final object not the object itself. I can change its reference in contructor if I put v=new Vector() in constructor. but here
AllFinals.java:5: Blank final variable 'v' may not have been initialized. It must be assigned a value in an initializer, or in every constructor. final Vector v; but If assigned value in initializer then
I am geting error AllFinals.java:15: Undefined variable or class name: v System.out.println(v.isEmpty()); ^ Now static { final Vector v; v=new Vector(); } making initializer static giving the same problem why? ^ Q2 Why top level class can not be static? Q3
here object a1 is of tyep AnInterface but reference of AnInterfaceImpl. Call method on this object is giving compile time error methodOne do not catch or throw Exception. But why
this compiles and with out and error or exception. Q4 why
Q1: The statement "v = new Vector()" is floating out there where your variable declarations belong. You can put it into an initializer block, e.g., "{v = new Vector();}" and it will work. Instead of: { final Vector v; v=new Vector(); } use: final Vector v; { v = new Vector(); }