java tells that can not find symbol -
i studying core java myself. wrote java program, , got 1 error:
...cannot find symbol "refc"
but is declared object reference... can explain that?
import java.io.*; class contactmain { int count = 0; int[] = new int[5]; contactmain() { system.out.println("a"); a[count] = count+1; count++; } } class contact { public static void main(string args[]) { int y = 0; int = 0; while (i<10) { contactmain refc = new contactmain();//create instance of class i++; } system.out.println(refc.a[i]); } }
in last statement, got error {refc.a[i]} cannot find symbol. please, me.
scope matters, you're declaring variable inside while(..){ }
, trying access outside of loop, change code to:
while(i<10) { contactmain refc=new contactmain(); i++; system.out.println(refc.a[i]); }
Comments
Post a Comment