Using a variables value as the name of another variable

Hi, i'm new to java and i've been trying to write a little program. I was wondering whether it is possible to use the value of a variable as the name of another variable.
This is what i have so far: When i run my java program numerous Animal objects are created with names like ani01, ani02, ani03. These objects have functions like getName() etc. When i type in one of these codes into the command line it gets stored in a variable called 'input'. Everything's fine up to here.
But i need a way to access the correct Animal from my input. instead of doing countless switch statements on the input.
If i type "ani02" i want it to return the animals name by calling ani02.getName()...
how do i do this? i'd appreciate any help. thanks.

If you were doing this based on user input, then you
wouldn't have to do a lot of typing. Mmm?I'm sorry i don't get your meaning... ? I am doing this based on user input am i not?
All i want to do is access the correct Animal object depending on the user's input... so if they type in ani01 it would return 'Elephant' (or whatever) using ani01.getName().
Maybe i'm going about this the wrong way or something?.. I have about 30 animals. they each have a name, continent, quantity. I have an Animal class that has functions like getName(), setName() etc. When the program starts, 30 objects are created
Animal ani01 = new Animal("Elephant",3000,"India");
Animal ani02 = new Animal("Panda",200,"China");etc...
I want to be able to get information about any one of these animals by typing something at the command line...
so i type in something (i just thought the name of the object would be the best thing to type in) and i get the info about elephants (or whatever) from the relevant object.
how would you do this?

Similar Messages

  • I recently got a message on my screen that says "the name of your computer is already in use on this network. The name has been changed to *

    I recently got a message with an exclamation mark stating "your computer name is already in use on this network. The name has been changed to ______"
    How did this happen, is it phishing, malware, or did someone hit some button on here to change it. I'm hoping that someone else doesn't have access to everything on my computer now. Help!

    Hello RaptorTrish,
    Interesting name!   You don't say what computer you are using, the OS or the nature of the network, home, office etc.    Could you fill in a few details.  
    You are right to be concerned but there is often a simple explanation.

  • HT5167 Error after 10.7.4 upgrade..."computer's local hostname ........is already in use on this network.  The name has been changed to......  What to do now to get it back to status before 10.7.4 upgrade?

    Error after 10.7.4 Lion Upgrade to iMac
    Computer's local host name .......is already in use on this network.  the name has been changed to........
    and it keeps adding up the number each time I wake the iMac.
    What to do to get it back before upgrade error?

    Ok worth repeating, hope this works.  Finally spoke to AppleCare Support and walked me thru following...restart computer holding down "command" and "option" keys at the same time with letters "P" and "R" when computer turns on.  This is what he called a PR restart, clears out discrepancies in memory (if that is what the error message actually is).  Then went to Systems Preferences/Network/Sharing and deleted the number that kept increasing every time MAC would wake up.
    Even tho this was just done, I am hopeful that error pop-up won't happen again.  Fingers crossed!

  • Every time i wake my mac i get This computer's local hostname "D-360.local" is already in use on this network. The name has been changed to "D-444.local".

    error message that my local host name is in use and the system generates a new one every time I wake my mac the error mssg reads This computer’s local hostname “D-360.local” is already in use on this network. The name has been changed to “D-444.local”.

    There are several possible causes for this behavior.
    1. Two (or more) computers on the local network have the same Bonjour name, such as "X's-MacBook-Pro.local". Resolve the name conflict by renaming one or more of them in the Sharing preference pane.
    2. You have two simultaneous connections to the same local network: probably Ethernet and Wi-Fi. If applicable, disconnect the Ethernet cable or turn off Wi-Fi.
    3. A Mac wakes from sleep due to network traffic. This is a bug in OS X that may only affect some models.
    4. A device that gets its network address from the router wakes from sleep, and the address it was using before has been assigned to another device.
    5. A third-party wireless router has incompatible settings or firmware. In that case, refer to the manufacturer or ISP for support. Restarting the router may help, temporarily.
    6. See also this support article.

  • What does this mean?  This computer's local hostname "Linda-Daviss-iMac-4.local" is already in use on this network. The name has been changed to "Linda-Daviss-iMac-5.local".

    What does this mean: This computer’s local hostname “Linda-Daviss-iMac-4.local” is already in use on this network. The name has been changed to “Linda-Daviss-iMac-5.local”.
    When I came back to my computer this message was on the screen.  Should I be concerned ? or doing something?

    Sometimes this message means that you have two simultaneous connections to the same local network: probably Ethernet and Wi-Fi. Disconnect the Ethernet cable or turn off Wi-Fi.
    Sometimes it happens because a device that gets its network address from the router wakes from sleep, and the address it was using before has been assigned to another device.
    Rename the computer in the Sharing preference pane.

  • Should I ok "this computer's local hostname Irma-Mac-mini-local" is already in use on this network. The name has been changed to Irma2 Mac-mini 2-local

    Should I ok this message-this computer's local hostname Irma's Mac-mini-local is already in use on this network. The name has been changed to Irma's Mac-mini-2local

    Don't think this is a conflict with IP Addresses or computer names
    = DHCP hangover when computer renews DHCP lease
    There is no actual other computer
    It just appears that way when reconnects so creates new -2 computer name
    What types of names do you use your computers ?
    Whether you name them after quantum particles or the romantic poets...
    They will each start to be appended with "-2" then "-3" etc if you auto configure network settings from Airport Router  DHCP service and you have this Change computer name issue where pop up window states name is already being used on your LAN
    As stated previous post you can reset the computer name in SysPrefs / Sharing / Edit button
    And restart Router or renew all DHCP leases (if persists in not allowing original name)
    Can now press Edit and reset name of choice
    But for Fix see link above

  • I get this message:This computer's local hostname "x-8.local" is already in use on this network. The name has been changed to "x-9.local" I have turned off sharing and it continues to upgrade name. What is the fix?

    I get this message: This computer’s local hostname “x-8.local” is already in use on this network. The name has been changed to “x-9.local” I have turned off sharing and it continues to upgrade name. What is the fix?

    Hi, this is a common problem, mostly just irksome though.
    It can have many cause, like using more than one Interface for connections, Router temporarily losing x.local & seeing a new connection with x.local already used, insists it must be x-1.local, x-2.local, etc..
    What all Sharing do you have enabled?
    Some possible fixes...
    http://forums.macrumors.com/showthread.php?t=542899
    https://discussions.apple.com/thread/3941367

  • HT3275 What if my error message is the following:  The backup disk image "/Volumes/********'s Time Capsul/****'s MacBook Pro.sparsebundle" is already in use. (I have redacted the name of the computer with asterixes)

    What if my error message is the following:  The backup disk image “/Volumes/********'s Time Capsul/****’s MacBook Pro.sparsebundle” is already in use. (I have redacted the name of the computer with asterixes)

    This is a complex procedure.  
    Pull the power cord from the back of the Time Capsule
    Wait a minute or two
    Plug the power cord back in to the back of the Time Capsule
    This will fix the issue 98% of the time. If you are in the unlucky 2% category, more help is here from Pondini, the Time Machine guru:
    The Backup disk image ... sparsebundle ... is already in use.

  • How to pass a value of the radiogroup to another page item

    Hi, I have a report with one column as a radiogroup. I have a process that execute the next code when I press a button:
    begin
    for i in 1..htmldb_application.g_f01.count
    loop
    update mesa_entrada set retomada = sysdate where id = htmldb_application.g_f01(i);
    end loop;
    end;
    I want to set the value of the item in another page with the value of the selected radiogroup, How i have to do?
    any suggestion will be welcome!
    Thanks!

    I have the same problem.
    On the new page the global variable HTMLDB_ITEM.G_F01 has 0 values.
    I created a process like this in the new page:
    :P300_FILENAME := HTMLDB_APPLICATION.G_F01.count;
    FOR I IN 1..HTMLDB_APPLICATION.G_F01.COUNT
    LOOP
    :P300_TEST := HTMLDB_APPLICATION.G_F01(I);
    END LOOP;
    and P300_FILENAME gets 0 and P300_TEST is empty. Any sugestions?

  • The name of this class conflicts with the name of another class

    I had a problem when compiling my flash movie. I had made an
    instance from a class, but the output kept saying:
    "The name of this class, XXX, conflicts with the name of
    another class that was loaded XXX."
    I read a lot of developers have the same problems, when i
    looked it up:
    Google
    link on : "conflicts with the name of antother class that was
    loaded"
    Apparently it is some kind of bug caused by different times,
    between local/network machines and servers.
    Also when there is a time difference involved between 2
    computers, then this problem also occurs.
    Can't macromedia fix this bug? .....Because as a developer i
    don't want to adjust my time, everytime i want to test my flash
    movies or have to compile my movie 2 times. The other developers
    are getting tired of it also.
    We need to get this bug trough to macromedia or adobe!
    It needs to be fixed!

    Can anyone help?

  • Revaluate function using a negative value in the revaluation variable

    Hello,
    I'm trying to use the revaluate function in IP, using a user defined variable containing a negative value, I have a error that tells me that the value in the variable is incorrect.
    I've tried several syntaxes, including "-10" or "10-" to revaluate the ratios at 90% of their original values, but without otaining any success.
    Has somebody an idea ?
    Regards,
    Mickael

    Hi Michael,
    we noticed the same and we created a simple FOX formula for this. This works fine then
    (One should use values like 0,5 I guess to devaluate which is not user friendly)
    D
    For example:
    DATA LV_REVALUATION TYPE F.
    LV_REVALUATION = VARV(Z_REVALUATION).
    = * (1 + ( LV_REVALUATION / 100)).
    (Z_REVALUATION is a variable type formula.)

  • Need to use Select List value as column name

    I want to have a WHERE ? IS BETWEEN ? AND ? clause.
    I am using the PL/SQL Query returning a SQL Query as a report. This uses bind variables for items I had set on my form..... If I hardcode something like:
    'WHERE STARTDATE IS BETWEEN '||
    'TO_DATE(:P1_START,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:P2_END,''dd-MON-YYYY HH24:MI'')';
    I have no problem, but I have 2 date columns, STARTDATE and ENDDATE, and would like to use the value in a select list and not have to hardcode "STARTDATE" in there. I have not been able to do this, does anyone know how to use a bind variable as a column name? From reading some posts I think it might not be possible.

    Heather,
    You're on the right track, just glue in the column name so that it becomes part of the returned query string from the function (...'WHERE '||:COLNAME||' IS BETWEEN '|| ...).
    Note that the bind variable is not part of the returned query string, but the column name obtained from the bind variable when the function executes does become part of the query string.
    Scott

  • What is the value of the 'Name' attribute of an Instance of Resource Type IPv6 Adress?

    See subject. I'm writing a Powershell script which is supposed to return the configured hostname and IP Address for a service associated with a role on a failover cluster. I'm using, e.g.. the following to retrieve the IPv4 Address:
    $a1 = Get-ClusterResource "MyServiceDisplayName"
    $b1 = Get-ClusterGroup $a1.OwnerGroup.Name | Get-ClusterResource | Where-Object {$_.ResourceType -eq "IP Address"}
    $c1 = Get-ClusterResource $b1.Name | Get-ClusterParameter | Where-Object {$_.Name -eq "Address"}
    and then I access the result via $c1.Value.
    I want to do the same for an IPv6 address. The information I don't have is the 'Name' attribute of the result of the Get-ClusterParameter command, that is the condition of the  Where-Object in the line which gives me $c1. (for the
    IPv4 Address I got it by running this on our test server, but that does not have IPv6 configured, so I cannot do the same in that case). Is it simply 'Address' as well?
    TIA, Thomas

    Hi,
    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
    Thanks for your understanding and support.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Use XML Node Value as Node name and as attribute name

    im quite new to XML and XLST. I got an Open Office XML file that I transformed with XLST.
    <?xml version="1.0" encoding="UTF-8"?>
    <ooo_calc_export scriptVersion="2.2.0" scriptUpdate="2010-12-19" scriptURL="http://www.digitalimprint.com/misc/oooexport/" scriptAuthor="vjl">
       <ooo_sheet num="1" name="Blatt1">
          <ooo_row><Artikelnummer>C12-34567</Artikelnummer><ArttikelnummerAlt/><Details>AAA AAA AAA AAA</Details><Abmessungen/><Bildpfad>file:///cmyk/C12-34567.PSD</Bildpfad><EK>1234,-</EK><VK>3456,-</VK>
            </ooo_row>
          <ooo_row><Artikelnummer>C23-45678</Artikelnummer><ArttikelnummerAlt/><Details>BaB BaB BBB BBB</Details><Abmessungen/><Bildpfad>file:///cmyk/cmyk/C23-45678.PSD</Bildpfad><EK>2345,-</EK><VK>4567,-</VK>
            </ooo_row>
          <ooo_row><Artikelnummer>C34-56789</Artikelnummer><ArttikelnummerAlt/><Details>CaC CaC CaC CaC uli</Details><Abmessungen/><Bildpfad>file:///cmyk/cmyk/C34-56789.PSD</Bildpfad><EK>3456,-</EK><VK>5678,-</VK>
            </ooo_row>
       </ooo_sheet>
    </ooo_calc_export>
    I transformed the XML with the following XLST:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
      <xsl:output method = "xml" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="ooo_sheet">
    <xsl:element name="Import">
    <xsl:for-each select="ooo_row">
    <xsl:element name="Artikel">
      <xsl:element name="Text">
            <xsl:copy-of select="Artikelnummer"/>
            <xsl:copy-of select="Details"/>
            <xsl:copy-of select="Abmessungen"/>
            <xsl:copy-of select="EK"/>
      </xsl:element>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    The result is:
    <?xml version="1.0" encoding="UTF-8"?>
    <Import>
        <Artikel>
            <Text>
                <Artikelnummer>C12-34567</Artikelnummer>
                <Details>AAA AAA AAA AAA</Details>
                <Abmessungen/>
                <EK>1234,-</EK>
            </Text>
        </Artikel>
        <Artikel>
            <Text>
                <Artikelnummer>C23-45678</Artikelnummer>
                <Details>BaB BaB BBB BBB</Details>
                <Abmessungen/>
                <EK>2345,-</EK>
            </Text>
        </Artikel>
        <Artikel>
            <Text>
                <Artikelnummer>C34-56789</Artikelnummer>
                <Details>CaC CaC CaC CaC uli</Details>
                <Abmessungen/>
                <EK>3456,-</EK>
            </Text>
        </Artikel>
    </Import>
    I need another child within the node "Artikel" named "Bild". It should have an "href" attribute. The value of the attribute should be the value in the node "Bildpfad".
    The result of this transformation should be
    <Artikel>
      <Text>
        <Artikelnummer>C34-56789</Artikelnummer>
        <Details>CaC CaC CaC CaC uli</Details>
        <Abmessungen/>
        <EK>3456,-</EK>
      </Text>
      <Bild href="file:///cmyk/C12-34567.PSD"></Bild>
    </Artikel>
    I want to import this XML into Indesign. It seems that the images path needs to be in a href attribute so Indesign accepts the node as an image object.
    Another problem is that Indesign won't import the original xml with selection of the listed xsl to tranform the xml. So I used another xml editor instead to perform the transformation.
    Thank you all for your help!

    Hi Dorian_fs,
    I think we're still missing details here on what exactly it
    is you're trying to do? Are you loading this XML via a data set? In
    which case, Don's samples would apply? Or are you trying to load
    XML independent of data sets and regions, in which case, you are
    looking for something that simplifies the access of data from the
    resulting XML document? If the latter than perhaps you want to use
    XMLDocToObject:
    http://labs.adobe.com/technologies/spry/samples/utils/XMLDocToObject.html
    --== Kin ==--

  • When I download something from the Web, the "Downloads" window opens, but the window remains blank. Before it used to at least show the name of the file and I could open the file from the "Downloads" window. Is there a way to get this functionality back?

    I'm running Windows XP which is updated to latest version (which I think might be Service Pack 3, but not positive.) Mozilla Firefox is version 5.0. I tend to use Google as my search engine so most of the stuff I download comes through sites found through Google, which is also updated.
    At some time in the past (maybe a few versions ago) when I would download a file from the Web, the "Downloads" window would open and in the window would be displayed the name of the file I was downloading or had just completed downloading. I think I used to be able to then click on that file name and the file (or the installation file if needed to start the new program) would open. I am currently using Firefox 5.0 (the "About Firefox" screen says this is up to date) and when I download a file or document, the "Downloads" window appears on the screen as it always has in the past, but it remains blank, i.e., nothing appears in the downloads box. I don't remember making any configuration changes, etc., that may have caused the window to remain blank, but I could be mistaken. I know how to find the items I've downloaded (My Documents / Downloads) and can usually guess what the name of the downloaded file might be, but it used to be much easier when something (anything) showed up in the downloads window.
    I'd love for someone to tell me about a simple fix for this. I'm willing to be quite embarrassed that I did something I shouldn't have.'''

    In Firefox Options / Privacy be sure "Remember download history" is checked. To see all of the options on that panel, "Firefox will" must be set to "Use custom settings for history".
    To find your OS information, on your Windows desktop, right-click the My Computer icon, choose Properties, under System on that small window is info about your OS.
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

Maybe you are looking for

  • 3rd generation iPod help needed

    ok, i tuned my ipod on & the screen is blank, but the music still plays. I've tried restarting it & the screen still is blank. someone please help me out.

  • Chart Axis Labels Not Always Accepting Style Properties

    I have two charts as seen in the following screenshot and in one my style properties are taking effect, in the other the style font size is not taking effect for one of the axis. I have this CSS which I know does affect some areas of both charts: Bar

  • I have forgotten my keychain password?

    I have forgotten my keychain password.  How do I fix this?

  • Settings of audit_syslog_level

    Hello, I have a technical question concerning the setting of parameter audit_syslog_level: we are recommended to audit events err, crit, alert and emerg. But in parameter audit_syslog_level I can only define one combination, for example: audit_syslog

  • Interface Builder does not open when I click Mainwindow.xib file on Monotouch.

    I did a lot research about it, What the most of view say it is because of the iOS SDK, not because of the MonoTouch, they say that iOS SDK provides the Interface Builder? Any suggestions? Thanks in advance. iOS SDK Version 4.3.