variable

Hi

I'm using 3 classes in 3 files A, B, C in a package letters. In the main class A, I define as a member an array public static double DateInput[] which I want to use in a method of the class B. But the array DateInput[] is not recognized. What should I change to have the possibility to use this array in the other classes ?

Thanks

[353 byte] By [new75javaa] at [2007-11-26 18:55:00]
# 1
You have to reference it as A.DateInput in class B. For this purpose, you can even drop the "public" keyword from the DateInput-declaration. This way, it will only be visible to classes in the letters package.
ProggerFromKupfera at 2007-7-9 20:32:37 > top of Java-index,Java Essentials,New To Java...
# 2

Arguably you shouldn't use fields in other classes anyway. Refactor your design so the methods that need the data live in the same class as the data.

Also it's good to follow java naming conventions. Fields start with lower case letters (unless they're constants, in which case they're all upper case).

paulcwa at 2007-7-9 20:32:37 > top of Java-index,Java Essentials,New To Java...
# 3
Thanks ! it works.I have already tried to create an object objA and to use objA.Dateinput[] but it didn't work.As you said I have to use the class and not the intance of the class :)
new75javaa at 2007-7-9 20:32:37 > top of Java-index,Java Essentials,New To Java...
# 4
I can't put the data in the same class because I want to create many intances for the class B and I want to use the same array for all the objects of the type B.I shall follow java naming conventions. Thanks
new75javaa at 2007-7-9 20:32:37 > top of Java-index,Java Essentials,New To Java...
# 5
> I can't put the data in the same class because I want> to create many intances for the class B and I want to> use the same array for all the objects of the type> B.Then put the data in B and make it static.
paulcwa at 2007-7-9 20:32:37 > top of Java-index,Java Essentials,New To Java...