Results 1 to 3 of 3

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

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    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
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: access array from another classes in java

    Not sure if this would help or not?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    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
  •  



Click Here to Expand Forum to Full Width