[RESOLVED] access array from another classes in java
what is the best way to access the array from different classes?
do i replace foo with the class that im in?
do i replace arr with the array i want to get?
thanks
Code:
////////////////////////
class Foo{
private int arr[];
public int[] getArr(){
return this.arr;
}
}
//from other class now
new Foo().getArr();or else it needs to be static
///////////////////////////////////////////////
class Foo{
public static int arr[];
}
//from other class
int arr[] = Foo.arr;
Re: access array from another classes in java
Not sure if this would help or not?
1 Attachment(s)
Re: access array from another classes in java
i finaly got it figured it out ,in my googling it for many hours ,some people say its a bad practice moving an array to other classes but its faster than sending 1 number at a time.
thanks all