Doubt in interface...
interface I {
int f(int x);
int var = 4;
}
public class C implements I {
public int f(int x) {
return x * x;
}
public static void main(String[] args) {
try
{
I[] a = new C[I.var];
System.out.println(a.length);
System.out.println(a[0]);//output - null
System.out.println(a[1]);//output - null
System.out.println(a[2]);//output - null
System.out.println(a[3]);//output - null
for (int i=0; i<a.length; ++i)
{
System.out.println(a.f(i));// Null pointer exception
}
}catch (Exception e){
System.out.println("Error: "+e.getMessage());// error in this line
e.printStackTrace();
}//catch
}//main
}//class
question: i have to call f() which is in interface a.length times. how?>

