954,224 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Operator Defining

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

venomlash
Junior Poster
143 posts since Oct 2006
Reputation Points: 86
Solved Threads: 2
 

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

Ezzaral
Posting Genius
Moderator
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

Okay, num_reasons_why_cpp_better_than_JAVA++;
thanks anyway, Ezzaral.

venomlash
Junior Poster
143 posts since Oct 2006
Reputation Points: 86
Solved Threads: 2
 
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.

Ezzaral
Posting Genius
Moderator
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You