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
Post a Comment