Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how do i create a vector within a vector ?

Reply
Thread Tools

how do i create a vector within a vector ?

 
 
learningjava
Guest
Posts: n/a
 
      10-17-2003
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
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      10-17-2003
On 16 Oct 2003 21:06:06 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (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.
 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      10-17-2003
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.

 
Reply With Quote
 
Paul Lutus
Guest
Posts: n/a
 
      10-17-2003
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

 
Reply With Quote
 
learningjava
Guest
Posts: n/a
 
      10-17-2003
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.

 
Reply With Quote
 
Miguel De Anda
Guest
Posts: n/a
 
      10-17-2003

"learningjava" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...

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


Does framework = homework?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM
vector within a vector Angela C++ 4 11-13-2003 03:24 PM



Advertisments