I am a bit confused...
by the Vector.contains method.
I am obviously not understanding some facet of this method. I am trying a pretty
simple use of it and getting incorrect results:
//just adding some static initial values to test...
claimTypes.add("A");
claimTypes.add("H");
claimTypes.add("I");
claimTypes.add("N");
claimTypes.add("O");
claimTypes.add("V");
//the getValue function for this class returns a string...
ID_Type = Type.getValue(claim);
if(claimTypes.contains(ID_Type)){
//do some stuff if it matches
}//end if
what am i doing wrong? am i gonna feel like an idiot when i get the answer?
most likely, but i appreciate it nonetheless! thanks
[1103 byte] By [
pnandrusa] at [2007-11-26 17:31:31]

Looks like it should work to me,
public static void main(String[] args) {
Vector<String> claimTypes = new Vector<String>();
//just adding some static initial values to test...
claimTypes.add("A");
claimTypes.add("H");
claimTypes.add("I");
claimTypes.add("N");
claimTypes.add("O");
claimTypes.add("V");
//the getValue function for this class returns a string...
String [] ID_Type = {"D","L","H","A","V"};
for(int i = 0; i < ID_Type.length; i++)
{
if(claimTypes.contains(ID_Type[i])){
//do some stuff if it matches
System.out.printf("Found %s%n",ID_Type[i]);
}//end if
}
}
//OUTPUT
Found H
Found A
Found V
~Tim
Put some println's in your code to see if what you think is happening really is happening. I would print out the ID_TYPE string, and the Vector, to check what's going on.
~Tim
> You don't show what the variable claim
> is.
>
> How am I supposed to know what
> Type.getValue(claim)
returns?
>
> Please post ALL of your code and explain what is
> incorrect.
Just a guess, but you probably code catch a clue from this line in the original post
//the getValue function for this class returns a string...
ID_Type = Type.getValue(claim);
~Tim
well, it just started working. I think Type had a different value in some of the tests
i was running than what i thought. I checked it a bunch of times when it didn't run,
but now all of a sudden its working right.
my problem is that i research stuff and then as soon as i post BOOM most of
the time it either fixes itself or i discover the solution (which is usually much easier
than i thought), so i feel like an idiot!
thanks for your time!