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
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:
- What is the difference between a static method and class method in Python?Best solution by pythoncentral.io
- Why cannot we use static keyword inside a method in java?Best solution by Stack Overflow
- How to get actual return type of a generic static method in Java?Best solution by stackoverflow.com
- How to Get Main output into Common() method in Java?Best solution by pages.cs.wisc.edu
- A question about ebay return.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.