-2

I am fairly new to java and was wondering, if I had a two classes as follows:

public class Class {
    char[][] charArray = new charArray[100[10];
}
class OtherClass extends Class {

}

Would the OtherClass class be able to access charArray? If so, how do you do it?

Franklin
  • 59
  • 2
  • 5

1 Answers1

0

Please look at answer here: sharing-variable-only-between-two-classes-java

Question is slightly different, but in answer there is basic about visibility in Java.

In short:

for your example charArray from Class will be visible from OtherClass only if both classes are in the same package.

To make it visible by child classes from any package it must be either public char[][] charArray or protected char[][] charArray

Community
  • 1
  • 1
Vadim
  • 4,027
  • 2
  • 10
  • 26