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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -