Results 1 to 3 of 3
  1. #1
    straw is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default calling a 2D Array from a different class

    hi all, i need to call a 2D array from a different class, here is what i have so fare:

    Java Code:
    public class Class1{ //not my main class but were the Array is located
        String Array[][]=new String[10][50];
        
        void classA(){
        showArray();
        }
        
        void showArray(){
            System.out.print("Array is: \n");
            for(int i=0; i<5; i++){
                for(int j=0; j<25; j++){
                    if(Array[i][j]==null)
                        break;
                    
                    System.out.print(Array[i][j]+", ");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
    now i need to know what to put in second class to use the array(call the array to the second class, then use it), e.g. if i wanted to populate the array, edit the array, search the array etc.

    any help appreciated!! =]
    thanks in advance!
    Last edited by straw; 03-03-2010 at 01:25 AM. Reason: wording missunderstanding

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You may help us help you by explaining just what you are trying to achieve in non-programming terms. Why do this? What's the goal?

    This article may help you to get help here: smart questions

    For instance, what is going to be held by this array? What purpose does the class that holds it have? What are the other classes doing? What will they need the information in the array for? etc....

    The more pertinent info we can get, the better we can help you towards a satisfactory solution.
    Last edited by Fubarable; 03-03-2010 at 12:31 AM.

  3. #3
    straw is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default

    ok class1 holds the array (a string array), class2 will be used to populate it, then maybe edit it, then maybe sort it. what it says in the original post but hope that clarifies it, any help?
    Last edited by straw; 03-03-2010 at 12:47 PM.

Similar Threads

  1. Child-Class Calling a Method in a Parent-Class
    By Blah_ in forum New To Java
    Replies: 5
    Last Post: 09-29-2009, 03:48 AM
  2. Calling a class method from another class
    By caro in forum New To Java
    Replies: 4
    Last Post: 06-10-2009, 02:12 AM
  3. problem calling function from class to class
    By alin_ms in forum New To Java
    Replies: 3
    Last Post: 12-19-2008, 08:35 PM
  4. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 01:25 AM
  5. calling array from main
    By nalinda in forum New To Java
    Replies: 1
    Last Post: 11-17-2007, 10:41 PM

Posting Permissions

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