question about interfaces

hey all

i have an interface called Sortable and i have a method in another class that class that takes as parameter an array of Sortable (e.g. methodName(Sortable[]))... i need to make this method to take instead of an array of Sortable a Vector of Sortable... but i dunno the right syntax...how should the parameter be written....

please help

thanks in advance

[386 byte] By [fouadka] at [2007-11-26 22:48:31]
# 1
Don't use Vectorwhatever(List<Sortable> blah) http://java.sun.com/docs/books/tutorial/collections/ http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
jverda at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...
# 2
> whatever(List<Sortable> blah)Or possiblywhatever(List<? extends Sortable> blahso that you could pass it a List<SortableThing> where SortableThing is a class implementing Sortable?
DrClapa at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...
# 3
Good point.
jverda at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks all for your suggestions but im obliged to use vectors...please help
fouadka at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...
# 5
Same principle applies: Vector(<? extends Sortable> blah).Which should be apparent if you'd read the links I provided.
jverda at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...
# 6

> thanks all for your suggestions but im obliged to use vectors...

You may be coerced into using Vectors for your List implementations, but you can still

do the right thing when writing a method:

import java.util.*;

interface Sortable {}

public class VectorExample implements Sortable {

public void whatever(List<? extends Sortable> x) {}

public void f() {

whatever(new Vector < VectorExample > () );

}

}

DrLaszloJamfa at 2007-7-10 12:08:22 > top of Java-index,Java Essentials,Java Programming...