• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we have two methods in a class with sama name but different return type?  RSS feed

 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can we have two methods with same name but different return types in a class ?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is your opinion? you cant have two methods with same signature[name and parameter] in a class

just for an information : however,Nested class can have a method which is already defined in Outer class, but it is different
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Seetharam.

Seetharaman Venkatasamy wrote:what is your opinion? you cant have two methods with same signature[name and parameter] in a class

just for an information : however,Nested class can have a method which is already defined in Outer class, but it is different
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nagaraj Shivaklara wrote:Thank you Seetharam.

you are welcome

so, in your case you are concern with only method *name* insteadof signature, so overloading[reusing name] is possible .
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Seetharaman,

Thank you, also i posted one exception which i am getting while doing struts project(under Application Frameworks » Struts) ..

Can you please help me with that?

Seetharaman Venkatasamy wrote:
Nagaraj Shivaklara wrote:Thank you Seetharam.

you are welcome

so, in your case you are concern with only method *name* insteadof signature, so overloading[reusing name] is possible .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!