File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Vector issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vector issue" Watch "Vector issue" New topic

Vector issue

mou haj
Ranch Hand

Joined: Sep 12, 2001
Posts: 81
I have a vector which stores say searches which the user performs in his session.. and in a page called previous search page I show them in the order they were searched.


now say if the user accesses search 2

Search 2
should be the 1st element
ie the 0th element..

ie I was the last accessed element to become the 0th elemnt and the rest moved back or what ever....

How to do this...

Please help
[ June 04, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Re-ordering the elements of a vector is a plain-old Java task. Nothing to do with JSP, so I'm moving this off to the Java in General(beginner) forum.
[ June 04, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Siyaa Hoffman

Joined: Jan 15, 2004
Posts: 23
I think you should consider using LinkedList in Java Collection Framework in Java2 instead of Vector.

It has methods like addFirst(),addLast() etc. which none other container has.
Richard Bradford
Ranch Hand

Joined: Apr 20, 2004
Posts: 48
If the search is a string you could do the following:

String temp = myVector.elementAt(index);
I agree. Here's the link:
subject: Vector issue
It's not a secret anymore!