How can I get a method to handle the return type flexibly?

I coded an abstract class implementing an abstract method called retrieve(int index). When I inherit from that class and add an implementation for that method I want to be able to return any primitive values as well as any objects. In effect the method should look like this in several child classes:
public int retrieve(int index)
for a child class handling ints, or this:
public float retrieve(int index)
for a child class handling floats, just as well as this:
public Object retrieve(int index)
for a child class handling objects.
How do I have to define the abstract method to get this behaviour?
Thx for all help, it's much appreciated!

Yes, agreed - return Object.
If you know you've got a class which can provide an
int and are thus expecting an int, what you can do is
provide a "retrieveInt()" method in that subclass
(which would be simply "return ((Integer)
retrieve()).intValue();") and call it via casting
(you can cast, since if you're expecting an int then
you know this class provides one, right?)
If you don't know that you've got a class
which can provide a primitive, then you won't be able
to write the code to use that primitive anyway, so
wanting to return them is barking up the wrong tree.
Er - that "explanation" may be as clear as mud ;o)Good idea, but this is how it works right now. But instead of having a retrieveInt, retrieveFloat and so on, I'd like to have one method name for all occurances.

Similar Messages

  • How can i get my car to change the track when i am listening to the music on my phone through the line-in?

    how can i get my car to change the track when i am listening to the music on my phone through the line-in? is there a app i can download so it will recognize it? i have a vauxhal astra and the controls are on the steering wheel

    First question is how old is Astra and you are in UK ( well you must be to have a Vauxhall)
    Normally the Radio only has a line in socket  to allow sound
    You have two choices here either a simple cable with a 3.5mm Headphone plus at each end
    or a cable with the headphone plug to place in car's line in plug and a wide Apple socket to fit the base of your iPhone This allegedly gives better sound but  you have to control the iPhone for music selection
    The equipment you need to control the iPhone from the Steering Wheel controls ,which I suspect currently handles radio /Cd  tracks /stations ,is much more complicated it will have to be integrate with the Factory Fitted  radio
    and designed to manage the S/Wheel  controls and translate to the iPhone .
    Fitted into back of radio etc etc
    If car is a recent Vauxhall there may be a kit available from them .but will not be cheap
    Many imponderables you did not give much away in your OP

  • HT204411 how can i get music only available in the u.s.?

    how can i get music only available in the u.s.?

    Travel to the US and supply a payment method valid there, or find another source for the music.
    (84673)

  • How can I get a new copy of the Voicemail app for my LG Spectrum?

    How can I get a new copy of the Voicemail app for my LG Spectrum?  It no longer works....the screen say Loading please wait....the
    !Visual Voice Mail - A Visual Voice Mail error has occurred.  Please try again. OK   I've tryed several times with the same message.  I've
    deleted the app from my screen and replaced it from the Apps Library....still the same message.
    I cannot find an answer on MyVerizon.  Any ideas?
    Thank you,
    Dee

    OK, at least 3 is working.
    I don't know how you have a Tape Recorder icon on your Home Screen. I cannot add one myself. But, I am running Holo Launcher in replacement of the default LG "Optimus" User Interface. It's much better in my opinion.
    Try long pressing the icon and select Edit and maybe you can change some attribute of the icon.
    Another thing you could do, is long-press an empty area of your desktop, to add an icon. Select Shortcut, then Select Contact, and scroll through your contact list and choose the contact that you added for *86.
    You realize if you have voice mail you haven't heard, there is a tape recorder icon in the notification bar, which you touch and pull down, then press it to dial voicemail.
    If that functionality doesn't work, you MIGHT want to consider doing a factory data reset on your device, but that is going to nuke all your personalizations and cause you work to set up again.

  • I had my ipod synced to an old computer that I no longer have how can i get all my stuff on the new itunes without erasing it

    I had my ipod synced to an old computer that I no longer have how can i get all my stuff on the new itunes without erasing it

    Most Windows users don't.
    Purchase an external hard drive and use the backup software that comes with it to backup files from your computer.
    Buy TouchCopy and install it on your new computer, connect your old iPod and transfer your songs to your computer.

  • I had an apple ID which I used for iCloud.  I upgraded the iCloud account and changed the apple ID to a @me address. Now I can't view what was in my original apple ID account.  How can I get what was stored on the original account?

    I had an Apple ID which I used for iCloud.  I upgraded the iCloud account and changed the apple ID to a @me address. Now I can't view what was in my original apple ID account.  How can I get what was stored on the original account?

    cathorio wrote:
    I recently changed my lap top. My problem is the new lap top won't accept my apple I D it asked me to sing up for a new one which I did.
    I am puzzled by this. The laptop doesn't need the Apple ID - but iTunes does. I could be missing something but ....
    Why would you not be able to use your existing Apple ID and iTunes account on a new laptop? If you authorized the computer - you should be able to use your existing account - unless you already had 5 computers authorized with the existing ID - and that was why iTunes would not accept the ID. However, I'm sure that you would have received a popup message from iTunes telling you that you had reached the limit.
    I just received a new MBP and my daughter did as well. My entire family shares an Apple ID and we had no issues at all with my Apple ID and iTunes on our new computers and I did not have to sign up for a new account. Did you even try the old ID?

  • HOW can I get a GOOD copy of the iTunes software for my desktop?

    I solved MY corrupt firmware file problem!
    A little background- I deleted all Apple, iPod, and QuickTime software from my desktop PC and reloaded iTunes for the (I don't know how many) time. Same thing! Downloaded it again and used the "erase iTunes" option then reloaded again and had the same result. I then cranked up my old laptop and when I got to the Apple website, I was offered an opportunity to download QuickTime and took it. It came with iTunes if I wanted, so I took that too. After the download, I plugged in the Nano and it restored to Windows format. I did not want it to sync to the laptop, so I took it to the desktop and was able to sync with Nano and downloaded my tunes. TALK ABOUT HOKEY!
    WHY does the restore program have to be resident on MY PC or MAC anyway? Seems like I could just as simply download a current copy from Apple every time I want to restore.
    WHY doesn't Apple do something about this problem and let users know about the solution? Do they not want to grab a share of the Windows business? Here is an excellent opportunity!
    Now for my question.
    HOW can I get a GOOD copy of the iTunes software for my desktop? I now know it works! Is there a hidden file or folder I should delete before I make my next attempt to cleanup and download? Why isn't this information public?
    I spent over 30 years in the DP industry. PC is not my area of expertise, but this must be the most frustrating experience of my years.
    desktop   Windows XP  

    I THINK I have solved the problem. Can't be 100% because I don't want to try a restore. At least the Apple home page lites up correctly with quicktime now. It hadn't in the past.
    Thank you for your assistance. - LRB
    desktop   Windows XP  

  • How can I get an excel spreadsheet onto the iPad and make changes to it?  I need this for a meeting this afternoon.

    How can I get an excel spreadsheet onto the iPad and make changes to it during my meeting this afternoon?

    I just bought splashtop, you have to have your home computer online,and download the pc version.  I have used it ot watch movies and to "go to work" on my ipad.  It controls the desktop through the ipad.  Whiteboard by splashtop does that and more and is on sale.  The education director at the hospital I work at is using that one.
    Splashtop 4.99 remote desktop(or laptop) control. Whiteboard 9.99 is remote control and more 9.99
    Julie

  • I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5

    I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5 on Windows 7

    Put everything back the way it was.
    Them move the folder correctly.
    http://support.apple.com/kb/ht1364

  • Somehow my iTunes app has been put into the trash.  How can I get this and all of the stuff that was in it back to my Application folder?  I try to drag it out of trash, but it won't work.

    Somehow my iTunes app has been put into the trash.  How can I get this and all of the stuff that was in it back to my Application folder?  I try to drag it out of trash, but it won't work.

    Also, when I do try to drag it out of the Trash to put it back into Applications (on the Finder sidebar), it asks me to authenticate with the administration password.  I enter it, and then a window appears saying that I can't do that because I do not have permission to modify iTunes.  Please help.

  • How can we get a alert message in  the current browser we are using the mom

    how can we get a alert message in the current browser we are using the moment we have entered some data in
    the table...
    I need a popup alert the moment a new record is added in a table... in apex database is 11g xe..
    The idea is I am using a apex application. .The moment new data is added in the table ..I am alerted by a message window..that a new record has been added...
    Thanks
    Edited by: pauljohny on Jun 11, 2012 10:23 AM

    pauljohny wrote:
    how can we get a alert message in the current browser we are using the moment we have entered some data in the table...
    "Current browser"? When viewing anything, or just when using an APEX app?
    Ans .. Just when using apex app....even if the apex app is minimised ..The current browser will be the one where I am using apex app...
    What i am looking for some scheduler .. to check ..in the table every 5 minute for change if there is a change..then a popup alert be shown...
    Split it into [at least] 2 components, database and browser. I'd expect someone calling themself a "DBA Architect" to have some ideas about the database side of things, even if not clued up on JavaScript and AJAX?
    I dont think its a database isssue... When i say to check every 5 minutes ..it could be easily done via dbms_scheduler ...I am having issue in getting the popup alert message...
    in apex... Dont know wether there is a plugin like modal window(available from skill builder) which shall help in this scenario,.Or might be have to use java scripting and ajax ..
    and if it is that (Java scripting and Ajax) .....then shall have to be familiar with java scripting and Ajax...and this shall be a bit time consuming..
    Had a feeling this could be accomplished via java scripting and ajax.. ...but still looking for some easy way..

  • How can you get audio for  books on the kindle

    how can you get audio for  books on the kindle

    The audio inputs on Macs are line level inputs and not mic inputs.  You need a mic with a built in preamp (battery powered) or more conveniently a USB mic or bluetooth headset.

  • How can I get my iPad to connect the love film app to my Apple TV?

    How can I get my iPad to connect the love film app to my Apple TV?

    Have you confirmed that the app supports AirPlay? If it doesn't, then you'll have to connect via screen mirroring. See:
    http://support.apple.com/kb/HT4437
    and
    http://support.apple.com/kb/HT5209
    Regards.

  • How can you get an applet to obey the CSS z-index attribute?

    How can you get an applet to obey the CSS z-index attribute?
    I have a DHMTL page with a panel that I want to slide back and forth. But another part of the requirement is to have the panel look like it is sliding under another panel.
    The problem is that an applet is on the panel that slides. When the sliding panel move under the stationary panel the applet does not go under the stationary panel, but the reset of the sliding panel does render looking like it is sliding under.
    See below.
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~           #############***************           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #############^**************           ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    ~ has a z-index of 1
    # and * have a z-index 2
    # shows above ~ and below ^
    ^ has a z-index of 3What I am getting with the applet on the panel with a z-index of 2 is the following
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~           #############***************           ^ -
    - ~           #            ^             *           ^ -
    - ~           #  @@@@@@@@@@@@@@@@@@@@    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @@@@@@@@@@@@@@@@@@@@    *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #############^**************           ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    --------------------------------------------------------Where @ is the applet. Notice how the applet is on top of the ^ but the panel under it, ^, is under like it should be. All the panels are 1x1 tables with a border. So how can I get the applet on the drawing shown with # and * to follow the rendering of the z-index of 2?

    Hi,
    I have the same problem, and don't know how to solve it, So, i had tried to put my applet in a div tag wih z-index=0, but it still hide my other Dhtml divs with bigger Z-index (z-index =1000)
    Have you any idea to solve this.
    Thanks
    Hakim

  • I downloaded a Trial version of Adobe Acrobat XI.  Now the trial has runout and I've signed up for a subscription.  However, my software still needs a serial number.  How can I get a serial number for the installed software?

    I downloaded a Trial version of Adobe Acrobat XI.  Now the trial has runout and I've signed up for a subscription.  However, my software still needs a serial number.  How can I get a serial number for the installed software?

    There is no serial number and you don't need one. What you need for a subscription is to SIGN IN within Acrobat, so it knows the subscriptions you own.

Maybe you are looking for

  • Creating password protected PDF

    I can create a pdf file using com.lowagie.text.pdf.PdfWriter and other classes in com.lowagie.text But I want to make my PDF password protected. Is there any way to make it password protected while using com.lowagie.text API.

  • SOLVED: is usbip usb redirector working for anyone?

    I am looking for USB redirector, and naturally tried usbip package. So far, cannot make it work: #usbipd --daemon # ps -ef | grep usbip root 16722 1 0 22:28 ? 00:00:00 usbipd --daemon # lsusb Bus 004 Device 002: ID 05da:6080 Microtek International, I

  • Adobe Cs5-missing images from assets-folders.

    Hi, can anyone tell me how to fix this problem? I downloaded the trail version of adobe cs5 to learn how to build webpages. I've watched upto video 4 of the class-room modules before I realize that the *Assets-folder, has no pre-loaded pictures in th

  • Subreport header on more than one page ?

    <p>Hi all,</p><p> </p><p>I need to create some reports with big subreport inside !</p><p> </p><p><font color="#000099">Main report </font></p><p><font color="#000099">subreport1  (10 pages and 9 columns)</font></p><p><font color="#000099">subreport2

  • SSRS 2008 DateTime picker to UNIX/EPOCH field

    Im trying to write a report that presents data based on a date range(selected by the person running the report) using SQL Server reporting. I build the start date and the end date as parameters and as a selectable date/Time data type and create a dat