check string contain inside the string array
hi friends,
i have doubt
i have arry like this
String[] groups ={"Manager", "technical",programmer};
i have another string variable test = "manager", i want to check "manager" is contains inside the groups can any one suggest
like in oracle we have exists some this like this in java.
i want to check one string like "manager" exhists inside the group array.
thanks
[415 byte] By [
vinukaruna] at [2007-11-27 11:55:04]

> thanks for the answer, but i dont want to use loop,
> the same thing is there any way to do it with vector ?
Why don't you want to use a loop? Odd requirement. Is this homework?
> Store u r elements in vector by put()
Do not use Vectors. Old, slow, outdated. And pointless anyway - if theOP does not want to use a loop, he should add the elements to a Hashset, which does *exactly* what he needs without iterating.
> but how to check weather a string eg:"manager"
> exhists using a vector
>
> thanks
Use a HashSet, just as Rene said. It's better in this case. Do also note that the "search" will be case sensitive.
Kaj
kajbja at 2007-7-29 18:59:50 >

> Yes hASHsET BETTER THAN Vector
Everyhing is better than Vector. If you need a synchronized list, use Collections.synchronizedList(). If you don't need it synchronized: leave it altogether and use an arrayList or LinkedList or whetever suits you the most.