• Post Reply Bookmark Topic Watch Topic
  • New Topic

Arrays v. Enumerations in Servlet API  RSS feed

 
Frank Rennie
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some methods such as ServletRequest's getParameterValues return a String array whereas others (e.g. HttpServletRequest's getHeaders) return an Enumeration. Do these return types need to be learned parrot-fashion, or is there some sort of logic to it?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends upon when in time the APIs were added. Earlier methods return Enumerations, later methods return more sane results. The Javadoc is your best friend.
 
Ramy Nady
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank Rennie wrote: Do these return types need to be learned parrot-fashion, or is there some sort of logic to it?


Some times you will not have a reason for such difference.
There is no standard way of return type or even the method names on each class/interface.

Such names bring tricky questions on the certification exams

I agree java doc is the only reference you can depend on instead of guessing.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!