Map for Vectors

Discussion in 'Java' started by Marcelo, Jan 30, 2006.

  1. Marcelo

    Marcelo Guest

    Just a little question from a begginner,

    I would like to know if there is something like a "table" or a matrix of Vectors.

    I am actually looking for something similar of a "Vector of Vectors", does Java
    has a class that implements this?

    thanks a lot,

    Marcelo
     
    Marcelo, Jan 30, 2006
    #1
    1. Advertisements

  2. Hi Marcelo,

    Marcelo wrote:
    > Just a little question from a begginner,
    >
    > I would like to know if there is something like a "table" or a matrix of
    > Vectors.
    >
    > I am actually looking for something similar of a "Vector of Vectors",
    > does Java has a class that implements this?


    Yes, nearly exactly that:

    List<List<MyContentType>> matrix=new ArrayList<List<MyContentType>>();

    You may encapsulate this in your own class.

    Ciao,
    Ingo
     
    Ingo R. Homann, Jan 30, 2006
    #2
    1. Advertisements

  3. Marcelo

    Roedy Green Guest

    On Mon, 30 Jan 2006 11:24:08 +0100, Marcelo <>
    wrote, quoted or indirectly quoted someone who said :

    >I am actually looking for something similar of a "Vector of Vectors", does Java
    >has a class that implements this?


    You implement it literally with e Vector of Vectors, or more commonly
    ArrayList of ArrayLists.

    the generics to define the types get rather unwieldy.
    e.g.

    ArrayList<ArrayList<Dog>> matrix = new ArrayList< ArrayList<Dog>>(
    500);
    Now you must go and create the inner arraylists and within that the
    Dog objects.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Jan 30, 2006
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alex
    Replies:
    1
    Views:
    855
    Lau Lei Cheong
    Feb 4, 2005
  2. Matthias Hildebrand
    Replies:
    5
    Views:
    9,180
    krogers
    Mar 20, 2012
  3. Dekker

    A map of varying vectors

    Dekker, Mar 21, 2006, in forum: C++
    Replies:
    1
    Views:
    342
  4. Replies:
    3
    Views:
    322
    Daniel T.
    Aug 15, 2006
  5. grbgooglefan
    Replies:
    7
    Views:
    488
    James Kanze
    Dec 5, 2007
  6. Replies:
    3
    Views:
    900
    Shadowman
    Mar 26, 2008
  7. Xah Lee
    Replies:
    9
    Views:
    848
    Deeyana
    May 25, 2011
  8. Guest
    Replies:
    0
    Views:
    653
    Guest
    Sep 14, 2005
Loading...