Something wrong with one of my methods

Hi, im having a little trouble, I have a list of companies which I am storing in an arraylist an this is method below is simply suppose to display how many companies are in each state.
Now, as long as I have the try/catch wrapped around the while loop it seems to function correctly, however if I take it out, the program throws an ArrayIndexOutOfBoundsException error. However I cannot see where it would be trying to access an index that isnt there.
     public static void compState(ArrayList companyMaker) {
          String[] component = {"WA","NSW","VIC","QLD","SA","ACT","TAS","NT"};
          int[] amount = new int[8];
          int n=0;
          try {
               while (n <= component.length) {
                    System.out.print("\nThe companies in " + component[n] + ": ");
                    for (int i = 0; i < companyMaker.size(); i++) {
                         Company tempComp = (Company) companyMaker.get(i);
                         if (tempComp.getState().equalsIgnoreCase(component[n]))
                              amount[n] += 1;
                    System.out.print(amount[n]);
                    n++;
          catch(Exception e) {}
     }Any help would be great, because I really dont want to leave it the way it is.

i think thats a classical "off by one"-error
you have to be careful with the array.length
if you have an array with 8 elements, array.length would be 8, but the index starts with [0] and therefore ends with [7].
try to replace this line:
while (n <= component.length) with this one:
while (n < component.length)

Similar Messages

  • How do I import my photos from my iPhone to iPhoto, when I press import I just get a message saying there is something wrong with one of my photos and disconnects my iPhone.

    How do I import my photos from my iPhone to iPhoto, when I press import I just get a message saying there is something wrong with one of my photos and disconnects my iPhone.

    I couldn't find Image Capture at my first try, butI will try again. Do you inow how I can find the corrupted photo on my iPhone? Im a bit lost..
    Sorry, I just noticed, I made a mistake. "Image Capture" is in the Applications folder, not Utilities. And it may have a different name on your Mac, if your system language is not English:  Look for the icon with the camera:
    When Image Capture can import from your iPhone, spilt the folder with the imported photos in several small subfolders and try to import them separately to iPhoto. This way, you can identify a subset of photos with the corrupted one.
    Then try to import from that small subset one by one, until you hit the culprit. And then delete that photo or video from the phone.

  • There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator.

    There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator. However, when i lower it, my safari tab goes out of the screen. What do you guys think i should do? I'm getting very nervous.

    hey HAbrakian!
    You may want to try using the information in this article to adjust the behavior of your function keys to see if that resolves the behavior:
    Mac OS X: How to change the behavior of function keys
    http://support.apple.com/kb/ht3399
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • Just got an Ipad and am working on setting it up.  the one issue I am having with it is my screen will not rotate no matter what I do to the settings, I can't figure out if the settings are wrong or if there really is something wrong with my Ipad.

    just got an Ipad and am working on setting it up.  the one issue I am having with it is my screen will not rotate no matter what I do to the settings, I can't figure out if I have a setting wrong or if there really is something wrong with my Ipad.  any help would be greatly appreciated.

    Double click the home button (square)  and all the things you did are there.keep sliding the bar that will come up on the bottom to the left till it cant go anymore there should be a icon looking like this.press that and it should work
    Good luck hope it works.

  • Hi. Whenever I go through one of the menus in firefox, the links remain highlighted after my mouse passes over them. Is there a bug fix for this or is there something wrong with my computer? I am running windows 7 if that helps.

    Hi. Whenever I go through one of the menus in firefox, the links remain highlighted after my mouse passes over them. Is there a bug fix for this or is there something wrong with my computer? I am running windows 7 if that helps. This problem started ever since I upgraded to version 5.

    I have downloaded and used the iPod Reset Utility, alot that did. My current state is iTunes on my XP Home with SP3 sees the iPod. When I drag a song to the iPod, the Sync message appears for about 5 minutes, then the Apple symbol appears. But no song has been transferred to the iPod.
    I tried to tap into the XP iTunes database from my iBook, but although it acted like it would add the XP library to the iBook library, it did not. I've got 19 Gs of songs on the XP. If I have to load each song from its original CD to get it on my iBook I'm going to start looking for some other app or device so that I can listen to my music.
    It is a shame, in the old days, Apple techs use to look at what was going on, now it appears they don't, so they never know they have problems until Apple's profits fall.

  • Safari tries repeatedly to open a page. The page partially opens but then Safari reports that there's something wrong with page and I get an error message. This is happening at too many web sites for one site to be having issues.

    Safari tries repeatedly to open a page. The page partially opens but then Safari reports that there's something wrong with page and I get an error message. This is happening at too many web sites for one site to be having issues.

    I have a similar problem, Safari cannot load a complet page. It stalls e.g. ["38 of 42"]. sometimes it will complete loading after a long wait. just as often it will never complete the page,
    The same thing happens in chrome and firefox but safari on my iPad works just fine.
    I have the latest version of everything
    I assume there is a system problem but cleaning up permissions does not help

  • I must close mu iCloud account on my iphone but can't came in. Have no password and can't get a new one, have not the emailadress any longer and there is something wrong with my securityquestions.

    i must close mu iCloud account on my iphone but can't came in. Have no password and can't get a new one, have not the emailadress any longer and there is something wrong with my securityquestions.

    Hello Malin1951,
    Thank you for contacting Apple Support Communities.
    The following article should guide you through resetting your iCloud password so that you can close it on your iPhone.
    iCloud: Account troubleshooting
    http://support.apple.com/kb/TS3988
    Regards,
    Jeff D.

  • Is there something wrong with the IOS 6 update?

    Ever since I downloaded the iTunes IOS 6 update on my 2nd-gen iPad, I haven't been able to check my list of purchased apps in the purchased section the iTunes store app. I tried logging out & signing back in and I tried rebooting my iPad, but neither of them worked. Can you please fix the IOS update? Thanks if you and keep up the incredible work!

    Never mind, there's definitely something wrong with the IOS 6 update. Sometimes the App Store doesn't show that an app has been purchased & it only shows the price of the app. Other times, it doesn't show that an app is currently being downloaded or that it's installed.
    Still though, Apple, you really do need to fix this IOS 6 because the Purchased Apps section won't finish loading & display the ones that have been purchased. Also, you need to improve the App & iTunes gift card payment method because if you use a credit card & then switch back to gift card, it doesn't remember how much leftover money you had before & you can't combine the change from the previously-used ones together into one lump of money.
    32 cents isn't enough to buy anything, not even a $0.99 app. The money is going by without being used and its a waste of money! If it's possible, please fix these two problems. Thanks if you do & keep up the incredible work!!!!!

  • I have a Mid 2009 Macbook Pro 13 with no restore disk; it has OS 10.8.4 I believe there is something wrong with the OS due to I can not install flash player to view Youtube videos and the when we plug in a Bose headset the sound out will work sometimes

    I bough a used Macbook Pro mid 2009 that came with OS 10.8.9 it didn't have a backup restore disk with S/N W8******66D
    When trying to view some youtube videos; a window would pop up saying "it needs adobe flash player is required for video play back get the latest flash player" but after downloading the file and during installation would have errors and will not installed.....tried to reboot and install again.....but still the same.
    The othe thing I had noticed is when using a good Bose headset with mic the sound output would noticed the headset and then switch from headset to Internal speekers and headset.....thinking that there might be something wrong with the plug in port of the computer or the headset.....the headset works with no issues on my iPad so there must be something wrong with the computer.....tried to move the plugin around the port but no change....while the headset is plug in can hear a short clicking noise and the sound would get lost and back again......but with nothing plugin to the port there is no issue with the sound or mic.
    Thanks for your feed back......it looks like I have two different issues one is a software issue and the outher is a hardware issue
    <Edited By Host>

    The "restore disk" is built into the Mac. See About Recovery.
    Need more specifics about what error messages you got while installing Adobe Flash.
    However, you can almost avoid Flash altogether by setting YouTube to play the HTML5 version instead.
    Click the Try something new! link at the bottom of the YouTube page.
    I don't know about the sound issue. Might be hardware as you think. Try other headphones to check.

  • I synced. All my music disappeared. Now it will only sync my apps and not my music. Is something wrong with the port on my ipod, the USB cord, or Itunes?On Itunes it says I still have all my music. :(

    I synced my ipod to my computer and all my music disappeared. I tryed resyncing it and it would only sync my apps and not my music. I cant add music to my ipod. I something wrong with the USB port in the IPOD, the USB Cord, or ITUNES itself. Itunes still shows that all my music is there on my ipod. Itunes is recognizing that my ipod is connected, but it doesnt recognize that theres no music on my ipod anymore. Im so sad. Someone please help me. I miss my music.

    The music sync is one way - computer to ipod.  The only exception is itunes purchases.
    The ipod is not a storage/backup device.  It simply mirrors the selected content of your computer.
    As the music came from your computer in the first place, it should still be there and in your backup copy of your computer.

  • Is there something wrong with this table row definition?

    I have am supporting a coldfusion app that manipulates several forms.  One one particular page, there is a form that consists of several tables.  The last 3 lines of the last table are
        <tr>
                <td height="35" align="right" valign="middle">Description:</td>
                <td align="left" valign="middle"><input name="tmpPurpose" class="RptStd" size="70" maxlength="100" value="" onblur="document.ExpnDtl.Purpose.value = this.value;" onchange="ChkName(<cfoutput>#Session.CCWarn#</cfoutput>)" /><input type="hidden" name="Purpose" value="" />
                             <a href="#" id="aDesc" onclick="ShowHelp('9')" style="border:none; display:inline; padding: 0px 0px 0px 0px"><img src="/images/Help_Icon.gif" height="14" width="13" border="0" /></a>
                            </td>
          </tr>
          <cfif IsDefined("form.ExpnsCntrb")>
              <tr id="CntrbErr">
                   <td colspan="2" class="Error"><cfoutput>#form.ExpnsCntrb#</cfoutput></td>
              </tr>
          </cfif>
          <tr id="expnContrib">
                  <td align="left" valign="middle" height="35" class="RptStd" colspan="2">Is expenditure a contribution to a candidate, officeholder, or political committee?    <input type="radio" name="rdoCntrb" value="Y" /> Yes    <input type="radio" name="rdoCntrb" value="N" /> No</td>
           </tr>
          <tr id="COHInfo">
              <td colspan="2" class="RptStd" align="left" valign="middle" height="35">
                  <input type="checkbox" name="chkCand" id="chkCand" value="X" onclick="if (this.checked) document.ExpnDtl.btnCOH.disabled = false; else document.ExpnDtl.btnCOH.disabled = true;" />Direct expenditure to benefit a candidate or officeholder    
                  <input type="button" name="btnCOH" value=" Enter C/OH Information " class="RptBtn" onclick="window.open('/Testing/Test_COHBenefit.cfm?Parent=' + document.ExpnDtl.ItemID.value + '&Type=EXPN&Form=' + document.ExpnDtl.ExpnCode.value, 'CandidateInfo', 'width=730px,height=475px,scrollbars,resizable,location')" disabled /> <a href="#" id="aDirExpn" onclick="ShowHelp('11')" style="border:none; display:inline; padding: 0px 0px 0px 0px"><img src="/images/Help_Icon.gif" height="14" width="13" border="0" /></a>
              </td>
         </tr>
         </table>
    Now whne the form is displayed on my page, I always see the line of text Description and the line of text Direct expenditure to benefit a candidate or officholder (in bold above).  But I never see the line of text  Is expenditure a contribution to a candidate... (in italics above).   It seems so simple but I can't figure out why that line does not display!!  Is there something wrong with that tr/td definition?

    Have you tried removing the ID?  Just to see if some CSS might be using that ID with a display:none or visibility:none statement?

  • Is there something wrong with a Oscar Gomez Fuentes 2Channel oscilloscope

    Is there something wrong with a Oscar Gomez Fuentes 2Channel oscilloscope or are my devices configured wrong. I have DAQCard-6036E and SCC-2345 with SCC-Ft01 and SCC-A10 modules. The problem is that when I am measuring with A10 it effects to FT01's RMS and DC values. But when I am measuring with Ft01 everything is ok. So what's wrong?? I attached a picture of a front panel.
    Attachments:
    front_panel.JPG ‏132 KB

    Neuvos,
    Do any of the signals you are measuring have high output impedances (> 1 kOhm)? If so, you may be seeing cross-talk (or ghosting). Below, I have included links to a number of documents that discuss this issue and methods for eliminating it:
    Data Acquisition: Troubleshooting Unexpected Voltages or Cross-talk in Analog Input Channels
    Using a Unity Gain Buffer (Voltage Follower) with a DAQ Device
    Is Your Data Inaccurate Because of Instr
    umentation Amplifier Settling Time?
    Good luck with your application.
    Spencer S.

  • Is there something wrong with my Retina Macbook Pro?

    I have been looking at the Geekbench scores for the new retina model with 2.6GHz and 8GB of RAM and they are getting around 11-12 thousand as there final score. When I do it (I have the 2.6GHz model), I receive a score between 5-6 thousand. Is something wrong with my computer, or what?

    You can't really do a benchmark on your MB if you're running on batteries.
    Keep in mind, when you're running on batteries, your MB is not using your CPU's full potential since it's on power saving mode.
    Too do a proper benchmark, your MB must be plugged in to take advantage of your CPU's full power and your graphic card's power.
    I for one do not follow benchmarks anymore.  I used to when I used to build my own gaming rig with all the bells and whistles.
    But to be honest, you will never, ever put your MB in such extreme.
    If you're still not satisfied with your MB's performace, you can either follow or ignore my or sig's comments.

  • Is there something wrong with my battery?

    Hi everyone! I have an Iphone 5 that was newly "remodeled" for tmobile. I was wondering if there was something wrong with my battery after a recent decline in performance. I am updated to the latest iOS and I recently restored all of my settings on my phone in an attempt to increase battery performance, leaving only wifi on location for weather. With my current usage and standby, do I have something to be concerned about? I know some individuals that have my usage and will have a standby time of over a day. Advice and opinions is very much appreciated.

    Usage and Standby the same means that there is an app on your phone that is running continuously. Usually its an app choking on bad data, or trying to send and failing. There are a few troubleshooting steps you can try:
    Mail is a common culprit, especially if you have a Microsoft Exchange email account. If you do, go to Settings/mail,contacts,calendar, tap on the Exchange account, and turn off the switches. Then back out of settings and restart the phone (hold HOME and SLEEP until an Apple logo appears). Then turn the switches back on. This clears the mail, contacts and calender queues. It will take a while to resync content, so don't check battery condition until the resync is finished. And its best to do this with a WiFi connection as a lot of data may go by.
    If that doesn't fix it do the same with your iCloud account, and any other Push accounts you may have (Yahoo, gmail, hotmail, AOL).
    Next, look for apps that run in background (most of the apps in the Quick Launch ribbon do not run in background, but a few do - music and video streaming apps, Facebook, Twitter, Yahoo Messenger, Whatsapp, etc). Kill them in the quick launch ribbon by pressing HOME twice to display it, then hold your finger on any app until they all wriggle, then tap the "-" on each one. It won't do any harm to kill them all.
    Note that if you have Google Maps installed and you asked it for directions it won't stop tracking you until you actually kill it in the Quick Launch ribbon.
    good luck and report back!
    BTW, you will see a lot of posts blaming some specific version, now 6.1.4 (because it's the newest). But you will see just as many reports for 6.1.3, 6.1.2, ...5.1,...4.1...3.0, etc. It's nothing wrong with the version (except for 2.1, which had a real bug), it seems to be caused for some people by the upgrade process itself. But there are also many people who encounter this symptom far away in time from any upgrade.

  • My ipod is cracked and it chipped away a little more last night and that's when my wifi stopped working. My wifi works on every other device in my house except for my ipod. Is there something wrong with my ipod?

    My ipod is cracked and it chipped away a little more last night and that's when my wifi stopped working. My wifi works on every other device in my house except for my ipod. Is there something wrong with my ipod?

    Does the iOS device connect to other networks?
    Does the iOS device see the network?
    Any error messages?
    Try right next to the router
    Do other devices now connect?
    Did the iOS device connect before?
    Try the following to rule out a software problem:                 
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on your router
    .- Reset network settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - Wi-Fi: Unable to connect to an 802.11n Wi-Fi network       
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    If still problem and it does not connect to any networks make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar
    Could it be this?
    iOS: Wi-Fi or Bluetooth settings grayed out or dim
    One user reported that placing the iPod in the freezer fixed the problem. A trick that works frequently with iPhones:
    Settings > AirPlane Mode ON, Do Not Disturb ON
    Power down and wait 5-10 minutes
    Power up
    Settings > AirPlane Mode OFF, Do Not Disturb OFF
    If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
    Apple Retail Store - Genius Bar

Maybe you are looking for

  • Grey out custom field in VA02 line item

    Hi, We have this custom field in sales line item which we want to grey out after billing is done. I tried many things but it didn't wrk. I wrote simple code w/o checking any billing condition like          if screen-name = 'VBAP-ZZFIELD'.            

  • Still can't add printers in 10.4.7

    I've tried everything suggested in discussions including resetting printer system, fixing permissions and downloading & installing CUPS 1.2.2 but still same error adding printers. Both printers work fine over same network from Powerbook G3 running OS

  • Custom Report: Columns with headings merged

    Hello All, Is there a way to get a custom layout in reports as depicted in the following image - http://tinypic.com/r/20sbqtx/6 I can generate the simple layout with A, B1, B2 and B3 headings, but I'm not sure how and where to aggregate the B1, B2 an

  • EDI mapping for Shipment notice - SHPMNT05 to 940

    Hi, I had to map the SHPMNT05 IDOC to an EDI 940 structure. Was wondering if this is the right way to go for Shipment notices to Warehouses and if someone had a template for this particular mapping. Thanks, Karun.

  • RRI.............

    Hi, As per our discussion, I am sending you my requirement. call me if you feel any problem in this. My No. is : 610 733 7334. My Requirement is : In BW, I need to create a Jump query in RRI from Report to R/3 Transaction. Here  Sender value is i.e f