How do I override an object method in JavaScript?

Subclass method return type in Java question?

  • Hey, I need to know if it's possible to have subclasses with different PRIMITIVE return types. Right now what I'm doing is overriding abstract Object method() with wrapper classes like Integer method(). What I would like to do is be able to override it with int method(), short method() and all the other primitives instead of the wrappers. Thanks

  • Answer:

    No you can't. But boxed primitives (what the wrappers are called) aren't so bad. If you can guarantee that they're not null, then you can use them directly where you would use the primitive type, thanks to auto-unboxing.

Joe at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

No you can't. But boxed primitives (what the wrappers are called) aren't so bad. If you can guarantee that they're not null, then you can use them directly where you would use the primitive type, thanks to auto-unboxing.

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.