Priyanka Sumanam wrote:I have the below generics code
List<Object[]> resultset = queryObj.list();
for(Object[] aoirecord:resultset){
//logic to do with recordss
}
at the first line of this code , i.e., queryObj.list(); I get the warning
Type safety: The expression of type List needs unchecked conversion to conform to List<Object[]>
could any one please help on getting rid of this warning?
It's not what your program can do, it's what your users do with the program.
It's not what your program can do, it's what your users do with the program.
Joe Areeda wrote:
The problem is queryObject.list() is returning a List not List<Object[]>. The way to deal with it properly is to change the called method (IMHO) but there are still plenty of code in class libraries out there that don't implement generics.
That's what I believe.Jaikiran Pai wrote:
I don't know, but probably that API was written before generics were introduced?
It's not what your program can do, it's what your users do with the program.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
It's not what your program can do, it's what your users do with the program.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:Unfortunately, sometimes you just have to suppress warnings, because the generic type is no longer available at runtime. If it were a cast to List<Integer> would fail for a List<String>. But you probably suppress warnings quite a bit already, you just don't know it because the suppression occurs in other APIs.
It's not what your program can do, it's what your users do with the program.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
| Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |