Java Enumeration is a raw type. References to generic type Enumeration<E> should be parameterized
Enumeration is a raw type. References to generic type Enumeration<E> should be parameterized
forum.sun.com
--------------------------------------------------------------------------------------------
Hi,
I am getting a compilation warning at the statementEnumeration<String> params = (Enumeration<String>)request.getParameterNames();
I am facing problem in removing this warning.
I don't want to use @SuppressWarnings("unchecked")
Can anyone please help in removing this warning?
---------------------------------------------------------------------------------------------
I see two options. The first is to change request.getParameterNames() to return Enumeration<String> instead of Enumberation assuming that getParameterNames always returns Strings.
The other is to use a wild card enumeration instead of a Enumeration<String>. Since all objects can be converted to Strings it will allow you to use the Enumeration without getting any class cast exceptions
Enumeration<?> params = request.getParameterNames();
while (params.hasMoreElements())
{
String value = params.nextElement().toString();
}
댓글
댓글 쓰기
질문이나 의견은 요기에 남겨주세요 ^^,,