Sunday, 15 March 2015

java - Check value inside Map -



java - Check value inside Map -

i have map save values form name-group.

before doing operations, need know if map contains specific group, example: need check values containing group1 mark-group1.

i'm trying way:

if (checklist.containsvalue(group1)) { exists = true; }

i can't provide name when searching because there diferent names same group.

but isn't finding value, seems function looks entire value string , not part of it.

so, there way of achieving this, or need alter way i'm focusing code.

update--

this looking of map:

map<integer, string> checklist = new hashmap<integer, string>();

i load values database , set them map:

if (c.movetofirst()) { int checkkey = 0; { checkkey++; checklist.put(checkkey, c.getstring(c.getcolumnindex(travelorder.relation))); }while(c.movetonext()); }

the relation column, has values like: mark-group1, jerry-group1, lewis-group2, etc... so, map have construction [1, mark-group1], etc...

what need check if there value within map contains string group1 example, don't care name, need know if grouping exists there.

if want check value contain string substring have following:

for (string value : yourmap.values()) { if (value.contains(substring)) { homecoming true; } } homecoming false;

by way if values in map have 2 different parts, suggest store them in construction 2 fields, can searched.

java map

No comments:

Post a Comment