By mswatcher
via weblogs.java.net
Published: Dec 08 2011 / 08:18
Java has no operator overloading. I always thought that was a shame. For example, BigDecimal would be a lot more popular if you could write a * b instead of a.multiply(b).
Why doesn't Java have operator overloading? Well, C++ has it, and people kept saying that it makes code hard to read. Actually, in C++, you can have a library class vector and write v[i], thanks to operator overloading. In Java, we have unsightly v.get(i) and v.set(i, newValue). Easier to read? I think not.



Comments
Jonathan Fisher replied ago:
Operating overloading is all around a horrible idea. I'm glad it's difficult for Java and I hope never ever to see it.
Voters For This Link (4)
Voters Against This Link (0)