Results 1 to 3 of 3

Thread: [RESOLVED] access array from another classes in java

  1. #1
    Fanatic Member
    Join Date
    Feb 09
    Posts
    561

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

  2. #2
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,731

    Re: access array from another classes in java

    Not sure if this would help or not?
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  3. #3
    Fanatic Member
    Join Date
    Feb 09
    Posts
    561

    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
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •