Integer comparaisons not working so well

I am working on an encoding program, but I have a slight glitch when comparing Integers, here is the relevant code:
    public Association findAssociate(char toFind)
        /*  Post:   finds the association according to the key
         *          returns the association that holds that key
        System.out.println("Looking for: " + toFind);   
        int find=(int) toFind;
        Integer look=new Integer(find);
        for(int i=0;table!=null && i<26;i++)
Integer key=(Integer) table[i].key();
System.out.println("Key: " + key + " Integer: " + look);
if(look==key)
System.out.println("equal!");
return table[i];
System.out.println("OH NO! NULL!!!!!!!!!!");
return null;
the deal is, I have a table of associations, each holding a key and a value. The key is an integer holding an int that represents a char. For instance an a=97,b=98 etc as Java has defined.
When casting back into an Integer though, and comparing them, it does not find the correct equality. here is some sample output:
Looking for: n
Key: 116 Integer: 110
Key: 104 Integer: 110
Key: 119 Integer: 110
Key: 101 Integer: 110
Key: 110 Integer: 110
Key: 111 Integer: 110
Key: 105 Integer: 110
Key: 109 Integer: 110
OH NO! NULL FOUND!!!!!!!!!!!!!!!
I cant seem to find out why when the Integer key and the Integer look are the same the equality test still returns false. Any insights?

you are comparing object reference , not object values. You should only use == on primatives or to check if object references point to the same object
try something like
look.intValue() == key.intValue()) {
// whatever

Similar Messages

  • TS1702 How do I get a refund for an app that did not work/deliver well at all?

    How do I get a refund for an app that did not work/deliver well at all?

    You may not get a refund, but you can try contacting itunes support and asking.
    Click Support at the top of the page, then click the link under Contact Apple Support.

  • Worker does not work so well

    Hi everyone,
         I am trying to decrypt an encrypted video in my opne-source project SparrowPlayer(https://github.com/yatsen-yang/SparrowPlayer),and I found that decrypting the video may block the main thread for several seconds.It resulted in stopping renderring UI assets on the stage, which is unacceptable.So I think 'Worker' may do some help. I followed the example code of the online API about Worker(http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/system/Worker.htm l). I tested and it worked well.
         But I found that if I embed the BGWorker.swf in other class like com.xx.Test instead of in the document class, 'Worker' did not work so well.Sometimes main worker could not communicate with bgworker even that the state of bgworker is running.
    The example code followed:
        private function handleBGWorkerStateChange(event:Event):void
              if (bgWorker.state == WorkerState.RUNNING)
                      _statusText.text = "Background worker started";
                     bgWorkerCommandChannel.send(["startCount", 100000000]);
        It happened sometime, not everytime. If main worker send a message after 1 second when listerning that the state of bgworker is running, the code works well
        So it confused me. Logically, if the state of bgworker is running, it should mean that main worker can communicate with bgworker, and it works well if you embed the bgworker swf in the document class.But if you embed the bgworker swf in other class, you will have problem sometime.
        Finally, I found a solution.I embed the bgworker swf in other class instead of in the document class, and when bgworker initializes succesfully, it send a message to main worker.Main worker communicates withe bgworker immediately if it  receives the message coming from bgworker.Now the problem is solved.
        I want to know why the state of Worker not reliable when I embed the bgworker swf in other class.Is it a bug of Worker?   
        thanks

    We would need to debug it to definitively understand the problem.  I would recommend filing a bug with a simplified example that demonstrates the problem.  If you post the bug number here, I'll escalate it to the engineering team.
    Also, have you tried multiple browsers?  We can always do that triage here, but it would be an interesting data point.

  • TS1538 red dot glowing on proximity sensor of my iphone 4 and it is dead. it is not connecting with itunes. tried hard reset it's not working as well. also followed iphone troubleshooting assistant but also it's not working. what am i supposed to do now?

    red dot glowing on proximity sensor of my iphone 4 and it is dead. it is not connecting with itunes. tried hard reset it's not working as well. also followed iphone troubleshooting assistant but also it's not working. what am i supposed to do now?

    Make an appointment at the Genius Bar at your local Apple Store or take the phone into an Authorized Apple Service provider.

  • I keep getting a message that my ipad could not be activated because activation server is unavailable and when i try to use itune its not working as well.Plssss help

    i keep getting a message that my ipad could not be activated because activation server is unavailable and when i try to use itune its not working as well.Plssss help

    Has this iPad ever been jailbroken, had the OS rolled back, or used a beta version?

  • My mac won't restart, shut down, or go to sleep. And the volume and brightness does not work as well.

    My mac won't restart, shut down, or go to sleep. And the volume and brightness does not work as well.

    Connect the computer to the power.
    Hold the power button down for 10 seconds or more.
    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    Best.

  • What do i do if my home button is not working very well if at all on my ipod touch 4g

    my home button has not been working very well if at all lately. it really buggs me because i have to use the little assistive touch thing, it gets kinda annoying after using that for awhile. now i know that you can take it off and replace it your self most likely ( i know you can on the iphones at least) i just dont want to risk screwing up my ipod. any help will be greatly appreciated.

    Try:
    http://snapguide.com/guides/calibrate-your-home-button/?utm_expid=69945963-15
    fix for Home button
    iPhone Home Button Not Working or Unresponsive? Try This Fix
    - you can turn on Assistive Touch it add the Home and other buttons to the iPods screen. Settings>General>Accessibility>Assistive Touch
    - If not under warranty Apple will exchange your iPod for a refurbished one for:
    Apple - Support - iPod - Repair pricing
    You can do it an an Apple store by:
    Apple Retail Store - Genius Bar
    or sent it in to Apple. See:
    Apple - Support - iPod - Service FAQ
    - There are third-party places like the following that will repair the Home button. Google for more.
      iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

  • Change computer : Adobe suite is not working so well anymore

    Hi, I've just changed my professionnal computer & re-installed Adobe creative Suite standard CS but it isn't working well anymore
    Illustrator doesn't open all the file it should
    Indesign is so slow I can't work and shut when it's too busy
    Is there something I've forgot to install on the new computer?
    And I want to upgrade for CS4, will it be a problem since Creative suite isn't working so well anymore?
    Thanks for helping

    By chance it is still a Windows XP!
    The settings of the printer are the same that they were with the old computer!
    Illustrator : for exemple it doesn't open a file that I've used before, which is a .ai file! Why this file, I don't know! and my collegue can open it.
    Computer technicians here don't know anything about Creative suite, and Adobe won't help me because my version is too old (although I'd like to upgrade to CS4). It's crazy because I won't upgrade until the problem is not fixed!

  • My iPhone 4s screen is cracked and can't slide to unlock it.  Several of the icons are not working as well.  Is there a way to recover my photos if the phone has never had a back up or synced with another device?

    My iPhone 4s screen is cracked (due to being dropped) and I can't slide to unlock it.  Several of the the icons on screen will not work either.  Is there a way to recover my photos if the phone has never had a back up and never been synced with another device?

    kitts1979 wrote:
    My iPhone 4s screen is cracked (due to being dropped) and I can't slide to unlock it.  Several of the the icons on screen will not work either.  Is there a way to recover my photos if the phone has never had a back up and never been synced with another device?
    No in order to backup to iTunes, you would need to unlock your phone.
    In order to import pics to your computer you would need to unlock your phone.

  • [SOLVED]Trying to dual boot -- Not working so well.

    I've had arch and windows 7 dual booted before on this computer, but for some reason I cannot seem to replicate my initial steps to success.
    My current setup is:
    Disk /dev/sda: 320.1 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0003b81c
    Device Boot Start End Blocks Id System
    /dev/sda1 * 63 208844 104391 83 Linux
    /dev/sda2 208845 1269134 530145 82 Linux swap / Solaris
    /dev/sda3 1269135 32001479 15366172+ 83 Linux
    /dev/sda4 32001480 625137344 296567932+ 83 Linux
    Sda1 = Boot Partition
    Sda2 = Swap Space
    Sda3 = Root
    Sda4 = Home
    I'm trying to figure out how to add Windows 7 to this.  Now, one thing I have tired was to delete my home partition,  create an extended partition that would include space for a windows 7 install and another home partition.
    Basically split sda4 into two logical partitions.
    That works fine, I can reboot into arch linux and change the UUID in the fstab table to point to my new home directory, but on installing Windows 7 I have to have another partition for the 100mb sys reserve.
    Can I make 3 logical paritions in the current sda4 setup?  Then just have windows install to those two locations?
    Last edited by Si1v3r (2011-08-25 21:17:01)

    Inxsible wrote:
    I am not sure Windows 7 can be installed in an extended partition. It requires primary. also, it tends to create a 100 MB hidden partition for system files which probably needs to be primary as well. So right of the bat, you need to spare 2 primary partitions for Windows. You can however move your Arch install in an extended.
    take my advice, install Windows first and then re-install Arch. It'd be a lot easier.
    Windows MUST be installed to a primary partition.
    To successfully install Windows on the same disc as an existing Arch / Linux installation you will want to pre-create an Primary NTFS partition right at the front of the drive (to prevent Windows greedily using 2 of your total 4 primary partitions) and flag all you Linux partitions as "hidden" so the Windows installer cannot "see" them - this can be checked from the windows setup before committing to anything. Once Windows is installed you can the unflag the hidden linux partition and start re-establishing Arch. I can be done but it is time consuming and very easy to get badly wrong.
    This really is no mean feat as you will need to be familiar with moving partitions with gparted (from a liveCD), flagging partitions as hidden, reinstalling and reconfiguring grub etc etc.
    As inxsible says - it is easier (and quicker) to wipe your drive and install Windows 1st.
    Back up all your data onto dvd / ext usb, copy across any custom rc.conf etc files that have been tweaked along the way to somewhere safe - boot into a live ISO and nuke away. If you create your windows partition in advance you will only use 1 primary partition as stated above - leave it to the windows installer and you lose 2 to windows
    I would also suggest creating an extended partition and your logical partition layout for Arch from a liveCD / gparted once Windows is installed to smooth the Arch install process.
    If your previous Arch was installed from the old ISO - now would be a good time to grab the new one
    Last edited by satanselbow (2011-08-25 09:25:25)

  • Base integer manipulation not working on HP Prime Calc?

    I am a new user of the HP Prime Calculator.  Following page 585 of the user manual on integer manipulation.  I have entered a #100001100b number, and want to view its value in decimation or hexidecimal form.  I scroll up to select it.  Then I press the Shift, Base key (directly right of 3), but I do not get the Edit Integer dialog box.  I get a # entry like it expects a new number to be entered.
    What am I doing wrong?
    This question was solved.
    View Solution.

    After I had the same trouble updating my firmware, I found that the following procedure works.
    1. Manually put your Prime into firmware update mode by holding down the Symb key while performing a paperclip reset.  You will see "HP Prime recovery mode" at the top of the screen.
    2. Important: Connect the Prime to a USB 2.0 port that's as close to your motherboard as possible.  USB ports that are connected by an extension or a hub often fail, even if it's a powered hub.  USB 3 ports also have been known to fail.
    3. Navigate in Windows Explorer to the installation folder of the Connectivity Kit.  In 32-bit Winows 7, it's here:
    "C:\Program Files\Hewlett-Packard\HP Connectivity Kit"
    4. Run the "Updater.exe" program directly from that folder.
    That should work.  If not, I can only suggest trying another computer.  Some people have reported having no success with one computer, then success with another.
    -Joe-

  • WIFI and 3g not working very well together on 5s 8.1

    Since I have upgraded my iPhone 5s, the wifi conection is too instable and slow.
    I tried to reset all the settings but not resolve my issue.
    So, I found in the internet one hint that said to turn off the celular data while using the wifi. Doing this, the wifi connection works better, but it still slow and drop sometimes.
    Before the 8.1, everything was working perfectly.
    I tested the same wifi connection in my old iPhone with iOs 6 and in my MacBook, both work perfectly, but the 5S with 8.1, no.
    Does anyone have the same problem or know how to fix it?

    Use iTunes to restore your iOS device to factory settings

  • HT5594 Has anyone noticed that since downloading IOS 7, that Find my Friends, is not working that well.  It consistently shows my daughter in the River, when she is at home.  It worked great before the download, and now it is barely working.

    My daughter and I both have an Iphone 4S.  We use Friend finder to locate each other when we are in different parts of the state.  It worked wonderfully for like a year, until we downloaded IOS 7, and now it barely works.  Whenever she drives out of her neighborhood it seems to kick in and work ok, but still not great.  When she goes back to her apatment it shows her at her address for a split second, then it quickly jumps to another location far from where is actually is.  I also downloaded another Family finder app, and it shows the exact same thing.  I have a GPS tracker in the car, and it works just fine up there in the same neighborhood, so I don't know how the technology is different.  Can anyone help because she is 7 hours away from where I am in school, and I worry!!

    Thanks to all, tried both suggestions and they worked wonderfully, seems to be all OK now. Many thanks again!

  • Wifi on iPhone 5 not working, as well as, iPhone 4S with software update

    I just got the iPhone 5 and it will not connect to wifi.  I have tried to reset the network settings and turn off wifi then back on, nothing is working.  Also have an iPhone 4S that I just upgraded software on and now the wifi wont work on it either. I have a total of six apple products (iPhones/iPads) and the only ones no longer connecting to wifi are the ones that have the new software on them.  What is the problem?

    close out of the phone app, double tap home button and completely close out of the app.
    then do a reset, no data loss.  hold down the home/sleep button together until you see the apple logo and then release, then wait for your phone to boot back up.
    Then check voicemail again.

  • Wireless working, but not working very well.

    Lo there all,
    i followed the wiki and some threads here in the forums to set up a pci wireless card for my kids arch box. It is working, but could use some improvement.
    First off, it is an rt61 and the module that loads for it is the rt61pci. Cool enough. To get the thing connected after a boot, i have to put this in the terminal.
    iwconfig wlan0 up
    iwlist wlan0 scan
    iwconfig wlan0 essid myessid
    then i am on line, no problem...
    it connects by dhcp ( what i have in rc.conf )
    but.... it drops the connection every once in a while. .
    It's kinda random... after a long while or a short while, it just drops off. i think it has connected again,, but mostly it is off for good..
    So that is one question... what do i do there ?
    next.. .what do i put in rc.conf to not have to type stuff in the terminal every boot ?
    thanks

    ok, made some changes as recommended here.. here is what i have
    when i do ifconfig
    eth0 Link encap:Ethernet HWaddr 00:02:E3:0B:52:18
    inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
    inet6 addr: fe80::202:e3ff:fe0b:5218/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:514 errors:0 dropped:0 overruns:0 frame:0
    TX packets:524 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:452320 (441.7 Kb) TX bytes:72809 (71.1 Kb)
    Interrupt:5 Base address:0xc000
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:44 errors:0 dropped:0 overruns:0 frame:0
    TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:3332 (3.2 Kb) TX bytes:3332 (3.2 Kb)
    wlan0 Link encap:Ethernet HWaddr 00:14:85:D4:58:0A
    inet addr:169.254.227.0 Bcast:169.254.255.255 Mask:255.255.0.0
    UP BROADCAST MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
    wmaster0 Link encap:UNSPEC HWaddr 00-14-85-D4-58-0A-00-00-00-00-00-00-00-00-00-00
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
    what i find really strange about this is this address
    169.254.227.0 for wlan0.. where is that comming from??? it may be a neighbors router that sometimes shows up in iwlist wlan0 scan that shows up as linksys or something like that. But i shoud be associating our thing here right ?
    when i do iwconfig
    lo no wireless extensions.
    eth0 no wireless extensions.
    wmaster0 no wireless extensions.
    wlan0 IEEE 802.11g ESSID:"Bitsbam"
    Mode:Managed Frequency:2.437 GHz Access Point: 00:06:4F:51:0A:F8
    Retry min limit:7 RTS thr:off Fragment thr=2346 B
    Link Quality:0 Signal level:0 Noise level:0
    Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
    Tx excessive retries:0 Invalid misc:0 Missed beacon:0
    from rc.conf
    HOSTNAME="kidbox"
    lo="lo 127.0.0.1"
    wlan0="dhcp"
    eth0="dhcp"
    INTERFACES=(eth0 lo wlan0)
    gateway="default gw 192.168.1.1"
    ROUTES=(!gateway)
    in hosts
    #<ip-address> <hostname.domain.org> <hostname>
    127.0.0.1 localhost.localdomain kidbox
    in /etc/rc.local
    ifconfig wlan0 up
    sleep 3 &
    iwlist wlan0 scan
    sleep 3 &
    iwconfig wlan0 essid Bitsbam key s:krill
    i could not find netcfg2 in pacman, is it really necessary ? i can check somewhere else..
    thanks for the help gents.  Hope all this provides more clues

Maybe you are looking for

  • How do I resolve LOCKED DISKS problem ? NO ACCESS ANYMORE !

    Hello everybody, I've looked carefully where to post this topic, and I hope it's the right place here (I have already been warned not to post the same questions in different places). I have actually 2 internal volumes locked, 2 external Firewire volu

  • Hi There, i have a power mac g5, which has the following spec, can i upgrade straight from 10.5.8 to 10.7? or do i have to purchase 10.6 first?;

    Hardware Overview:   Model Name:          Power Mac G5   Model Identifier:          PowerMac7,3   Processor Name:          PowerPC G5  (3.1)   Processor Speed:          2.7 GHz   Number Of CPUs:          2   L2 Cache (per CPU):          512 KB   Memo

  • Downloading Multiple Images

    Hi all,              I am using NWDS 7.0. I have an requirement to download multiple image files. Images can be viewed by clicking the links provided in the tablecolumn. Images(JPG) are in mime folder. if i use the Fiel Download UI Element, it is ope

  • JMS Control to receive a message

    Hi all, I'm trying to createJMS Contro to test my JMS Server. A method to send a message was generated @Message(JMSControl.MessageType.Auto)      public void sendMessage(Object body);but I cannot find how can I write a method to receive a message. Ca

  • Since updating to LR 5.3 mac, program crashes on launch

    Anyone have any idea why 5.3 crashes at launch?   I've been using Lightroom since it was released many years ago, I've upgraded every version and done every update ... never had a problem till 5.3.  Now the program crashes on launch about once a day