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

Recommended Answers

All 3 Replies

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

Okay, num_reasons_why_cpp_better_than_JAVA++; thanks anyway, Ezzaral.

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.

commented: excellent point +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.