aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why getParameterNames() returns Enumeration, not String[] like getParameterValues()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why getParameterNames() returns Enumeration, not String[] like getParameterValues()?" Watch "Why getParameterNames() returns Enumeration, not String[] like getParameterValues()?" New topic
Author

Why getParameterNames() returns Enumeration, not String[] like getParameterValues()?

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Why GenericServletRequest.getParameterNames() returns java.util.Enumeration<java.lang.String>? Returning java.lang.String[] is much better, right? Like, java.lang.String[] getParameterValues(java.lang.String name).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

That's just the way it was defined way back when the servlet interfaces were first defined. It can't be changed without breaking backward compatibility, even though modern interfaces rarely return Enumerations anymore.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Faisal Ahmad wrote:Returning java.lang.String[] is much better, right? Like, java.lang.String[] getParameterValues(java.lang.String name).

Personally, I wouldn't use either. Were I defining the interface, I'd use a List.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why getParameterNames() returns Enumeration, not String[] like getParameterValues()?