1,105,633 Community Members

Operator Defining

Member Avatar
venomlash
Junior Poster
143 posts since Oct 2006
Reputation Points: 55 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

How do you define operators in JAVA? (Can you???)
[prettyplease] help? [/prettyplease]

Member Avatar
Ezzaral
Posting Sage
7,431 posts since May 2007
Reputation Points: 2,714 [?]
Q&As Helped to Solve: 953 [?]
Skill Endorsements: 31 [?]
Moderator
Featured
 
0
 

No, operator overloading is not possible in Java. The only thing you can do is add methods for the operations you need.

Member Avatar
venomlash
Junior Poster
143 posts since Oct 2006
Reputation Points: 55 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Okay, num_reasons_why_cpp_better_than_JAVA++; thanks anyway, Ezzaral.

Member Avatar
Ezzaral
Posting Sage
7,431 posts since May 2007
Reputation Points: 2,714 [?]
Q&As Helped to Solve: 953 [?]
Skill Endorsements: 31 [?]
Moderator
Featured
 
1
 

Okay, num_reasons_why_cpp_better_than_JAVA++; thanks anyway, Ezzaral.

Well, you are welcome to that opinion of course, but operator overloading isn't really all that special and probably causes more confusion than it's worth. It's syntactic sugar and might save you a couple characters typing, but you can achieve the exact same functionality with methods that perform the operations and no one has to wonder what "+" or "-" does in a given context.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article