• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic