how do i create a vector within a vector ?

Discussion in 'Java' started by learningjava, Oct 17, 2003.

  1. learningjava

    learningjava Guest

    I need to create an array A of vectors V.
    each Vector V contains three elements, Object a, Vector E.
    Vector E contains two or more elements, Object 1, Object 2 ....

    Can you give me a framework in java to do this?
    a test class for this will help too.

    Thanks,

    gk
    learningjava, Oct 17, 2003
    #1
    1. Advertising

  2. learningjava

    Roedy Green Guest

    On 16 Oct 2003 21:06:06 -0700, (learningjava) wrote
    or quoted :

    >Can you give me a framework in java to do this?
    >a test class for this will help too.


    see http://mindprod.com/jgloss/homework.html

    You need to break the problem into pieces. Give yourself a simpler
    problem to solve first. Put a single String into a Vector and get it
    out again. Then bit by bit add the complexities.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Oct 17, 2003
    #2
    1. Advertising

  3. learningjava

    Sudsy Guest

    learningjava wrote:
    > I need to create an array A of vectors V.
    > each Vector V contains three elements, Object a, Vector E.


    (that's only two...)

    > Vector E contains two or more elements, Object 1, Object 2 ....
    >
    > Can you give me a framework in java to do this?


    No! (It's already there for you)

    > a test class for this will help too.


    I'm sure it would, but that's missing the point. What you don't
    seem to grasp is that a Vector IS an Object.
    A Vector is also a collection of Objects. As such, it can
    contain anything else which is an Object, including other
    Vectors.
    IOW, Vectors can contain Vectors which contain Vectors, etc
    ad nauseum.
    What you need to be doing is analyzing the problem by reducing
    to the LCD. Since Arrays and Vectors are Objects at heart, try
    rethinking in terms of Objects without regard to class.
    Once you've done that then you can start looking at the
    instanceof operator and determine how you can use it in this
    particular problem scenario.
    Sudsy, Oct 17, 2003
    #3
  4. learningjava

    Paul Lutus Guest

    learningjava wrote:

    > I need to create an array A of vectors V.
    > each Vector V contains three elements, Object a, Vector E.
    > Vector E contains two or more elements, Object 1, Object 2 ....
    >
    > Can you give me a framework in java to do this?


    No, but you can complete your own assignment.

    > a test class for this will help too.


    Okay, then write it. Post your code when you have specific questions.

    Vector a = new Vector();

    Vector b = new Vector();

    Vector c = new Vector();

    a.add(b);

    b.add(c);

    Now Vector a has Vector b as a member, and Vector b has Vector c as a
    member. That's the basic idea.

    --
    Paul Lutus
    http://www.arachnoid.com
    Paul Lutus, Oct 17, 2003
    #4
  5. learningjava

    learningjava Guest

    Thanks, that helped.

    >
    > Vector a = new Vector();
    >
    > Vector b = new Vector();
    >
    > Vector c = new Vector();
    >
    > a.add(b);
    >
    > b.add(c);
    >
    > Now Vector a has Vector b as a member, and Vector b has Vector c as a
    > member. That's the basic idea.
    learningjava, Oct 17, 2003
    #5
  6. "learningjava" <> wrote in message
    news:...

    > Can you give me a framework in java to do this?
    > a test class for this will help too.


    Does framework = homework?
    Miguel De Anda, Oct 17, 2003
    #6
    1. Advertising

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. Angela

    vector within a vector

    Angela, Nov 13, 2003, in forum: C++
    Replies:
    4
    Views:
    379
    Dan Cernat
    Nov 13, 2003
  2. pmatos
    Replies:
    6
    Views:
    23,768
  3. Replies:
    8
    Views:
    1,910
    Csaba
    Feb 18, 2006
  4. Javier
    Replies:
    2
    Views:
    556
    James Kanze
    Sep 4, 2007
  5. Rushikesh Joshi
    Replies:
    0
    Views:
    354
    Rushikesh Joshi
    Jul 10, 2004
Loading...

Share This Page