Search:

Type: Posts; User: Norm

Search: Search took 0.17 seconds.

  1. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    That's been discussed here in this thread:

    aa.add(bb); // store 2d int array in an arraylist

    The print it part:

    int[][] bbbb = add.get(0); // get 2d array from arraylist...
  2. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    How you define the ArrayList depends on what you want to store in it.
    What do you want to store in the arraylist?
    How will you use what is stored in the arraylist?
  3. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    Sorry I don't understand where you have to make any classes. The code in post#14 was just an example.
    The code in post#12 should work.


    Check your requirements. Making arrays of ArrayLists is...
  4. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    The code is printing what the toString() method for a two dim int array returns.

    You need to go back and read what I posted earlier.
    The arraylist has ONE element: a two dim array of int.
  5. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    aa.get(y).get(x)
    Don't chain methods together. Use one statement for each method call so you know what data types you are working with.

    SomeClass smcls = aa.get(x);
    AnotherClass anCls =...
  6. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    An int array does not have a get() method.

    The ArrayList class's get() method returns an element from the arraylist. In this code that element is an int[][]


    int[][] bbbb = aa.get(0);
  7. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    You don't need the loops. Just add the array with one add statement.

    what do want in the arraylist? The code will have one element that is a 2 dim int array.

    There is no ArrayList array used...
  8. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    Use int[][] vs Integer[][] to define the arraylist and then you can add bb to it.
  9. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    Look at the API doc for the ArrayList class's add() method to see how to code it.


    Depends what is in the array list. For custom formatting, use a loop, get each item from the arraylist and...
  10. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    Do you get errors when you compile the posted code? If so, post them.

    You said:
    Please post what it does print when executed.


    HINT: For testing use a small array. For example: 3x4 not...
  11. Replies
    22
    Views
    1,163

    Re: storeing 2d array in arraylist?

    Can you post how it currently prints
    and add comments showing how you want it to print.
Results 1 to 11 of 11