3 ms·
As for definition, it already exists: https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html https://docs.oracle.com/javase/8/docs/api/java/lang/Number
by phoe-krk 6y ago
As for definition, it already exists: https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html https://docs.oracle.com/javase/8/docs/api/java/lang/Number.h...
As for abuse prevention: it would be impossible to use the common operators like +, -, +=, <<, >> and so on for anything that is not numbers, and therefore prevent C++ levels of overloading abuse.
- zokier 6y agoBut any class can inherit that Number, there is nothing enforcing that the subclass is particularly number-like. You can do just stuff like class MyString extends Number and you get access to operator overloads. Only thing that makes this annoying is Javas lack of multiple inheritance, but that is pretty minor thing.
- hinkley 6y agoThere is a level of stupid that is deniable, and a level that is not. MyString extends Number is going to lead more swiftly to words with your coworkers.