java - Can not convert from element type Object to Session -



java - Can not convert from element type Object to Session -

private static final set sessions = collections.synchronizedset(new hashset());

i storing sessions in set type reference variable called sessions s shown above.

now, want iterate on these:

for(session s : sessions){}

however, type mismatch error @ says

can not convert element type object session

how prepare ?

tl;dr: don't utilize rawtypes

you using raw set, means compiler can know set contains object.

you need specify generic type of collection:

set<session> sessions = collections.synchronizedset(new hashset<>());

for more information, read this.

java session servlets

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -