-2

I made an array, let's call it x[], and in a seperate function "xprint", I typed

public static void xprint(){
   System.out.println(x.length)

}

and it gave me: "cannot find symbol variable x"

why can't it see my array? they are both in the same class?

genisome
  • 47
  • 1
  • 1
  • 7

1 Answers1

0

It's because your function is static.

The array has to be static too in order for it to be visible.

If that is not the problem, you need to show more code.

avolkmann
  • 2,962
  • 2
  • 19
  • 27