aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vector issue" Watch "Vector issue" New topic
Author

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

Search3
Search2
Search1

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
Thanks
[ June 04, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Siyaa Hoffman
Greenhorn

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);
myVector.remove(index);
myVector.addElement(0,temp);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector issue