Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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
Posts: 65961
139
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
Posts: 65961
139
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!