Quantcast
Viewing all articles
Browse latest Browse all 54

[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;


Viewing all articles
Browse latest Browse all 54

Trending Articles