java - Warning: [unchecked] unchecked conversion -
i facing issue generics here. can please point me missing on in below statements?
1.
warning: [unchecked] unchecked conversion list<question> qlist = (list) session.getattribute("qlist"); ^ required: list<question> found: list 2.
warning: [unchecked] unchecked conversion list<examschedule> elist = new <examschedule>arraylist(); required: list<examschedule> found: arraylist i don't want supress warnings. suggestions appreciated.
list<question> qlist = (list) session.getattribute("qlist"); session.getattribute("qlist");return instance of typeobject. need explicitly cast it.(list)raw type,list<string>generic type , trying cast raw type generic type reference gives warning.
now, if this:
list<question> qlist = (list<question>) session.getattribute("qlist");
the cast runtime check there type erasure @ runtime, there's no difference between list<string> , list<foo> etc.hence error. try (list<?> list) type conversion verifies object list without caring types held within.
list<examschedule> elist = new <examschedule>arraylist(); that syntax error.it should arraylist<examschedule> , not <examschedule>arraylist.
suggestions :
list<?> qlist = (list<?>) session.getattribute("qlist"); list<examschedule> elist = new arraylist<examschedule>();
Comments
Post a Comment