Saturday, 15 May 2010

api - Clarity needed for indexOf method for Vector class java -



api - Clarity needed for indexOf method for Vector class java -

i have vector object string elements of varying content size 10,000 elements in vector object. instead of looping mad man, i'm thinking of using indexof first occurrence. simplicity:

string curnode = "0"; vector<string> stringvec = "1", "2", "3", "0", "1", "0", "1";

based on vector api here, if following:

int firstoccur = stringvec.indexof(curnode);

is guaranteed give me firstoccur=3 ? also, i'm not quite sure if string beingness immutable object, or violation of equals method comes play here.

returns index of first occurrence of specified element in vector, or -1 if vector not contain element. more formally, returns lowest index such (o==null ? get(i)==null : o.equals(get(i))), or -1 if there no such index.

that straight api. .indexof guaranteed homecoming first instance of object in vector, or -1 should object not found in vector. knowledge, index calls .equals() on objects, not == operator. there should no violations strings beingness immutable.

java api vector control

No comments:

Post a Comment