• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Method signatures in an Interfaces  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question is
Why we need to specify variable names in method signature of an interface methods ?

 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answser is "because the Java Language Specification says so". I think that it is rarely worth a great deal of effort to determine the exact reasons for particular language features. Just get on and learn to use the language, or, if you don't like it, learn another language!

In this particular case, I guess that the designers insisted on each parameter of an abstract method having a name, to increase the extent to which method signatures are self-documenting. But that's just my guess.
 
Manoj Agnihotri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks buddy.

It is just a question that suddenly came into mind.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the only effects these names have that I can think of is that they appear in the JavaDoc, and via reflection, and in the source itself of course. Which generally only matters to people trying to understand the method. Still, it seems worthwhile to me to have names here for precisely that reason. They're often helpful for understanding.
 
Manoj Agnihotri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree .

Thanks a lot.
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[QUOThey're often helpful for understanding.[/QB]

Indeed. IDEs like IntelliJ IDEA will use these names when then auto-generate method stubs for you, which also is quite helpful.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please check your private messages, Morpheous. Thanks.
 
Manoj Agnihotri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK...Buddy
I was not aware about that policy .
 
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
Yes, the only effects these names have that I can think of is that they appear in the JavaDoc, and via reflection, and in the source itself of course. Which generally only matters to people trying to understand the method. Still, it seems worthwhile to me to have names here for precisely that reason. They're often helpful for understanding.


Actually, parameter names are not used in reflection. All that is needed are the classes.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I misremembered that. Thanks.
 
today's feeble attempt to support the empire
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!