• 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
Posts: 65661
129
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: 65661
129
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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!