Please help in this code..

Hi,
I am developing one small program. Which has one inner class in parent class. I am using object [] array of that inner class. like thisPreferredRoomsItem maxPercentagePrefRooms[] = new PreferredRoomsItem[solutionOfTimeTable.MAX_ACTIVITIES];  
        for (int j = 0; j < solutionOfTimeTable.nInternalActivities; j++) {           
            maxPercentagePrefRooms[j].percentage=-1.0;
            maxPercentagePrefRooms[j].prefferedRooms.clear(); // test it.                                  
            double maxPercentage = -1;
            double minNRooms = INF;        
            for(PreferredRoomsItem it:activitiesPreferredRoomsList){ // check this code. this is incorrect/.
            if(maxPercentage<it.percentage || (maxPercentage==it.percentage && minNRooms>it.prefferedRooms.size())){           
                maxPercentage = it.percentage;              
                minNRooms = it.prefferedRooms.size();
                maxPercentagePrefRooms[j] = it;
            } In inner class PreferredRoomsItem it has two member variables. And then I am using iteration with for loop. When I am using this line-->maxPercentagePrefRooms[j]. it gives me nullpointerexception. Please help.
It is urgent.
Thanks in advance.

You still need to instantiate the Object in each array index.
for (int j = 0; j < solutionOfTimeTable.nInternalActivities; j++) {           
             maxPercentagePrefRooms[j] = new PreferredRoomsItem();
            //...

Similar Messages

  • Please help with this code....

    I create a button with ActionListner and a writeCd method. Now I want everytime i push the button, it will read the writeCd method. I dont' know how to make it work. Please help me out as soon as possible. Thanks a lot. Below are the codes of the button and writeCd method.
    class findCD implements ActionListener
    public void actionPerformed(ActionEvent event)
    //what do I need to put here to make the button work
    //with method writeCD() below
    public void writeCd() throws Exception
    String outputFileName;
    PrintWriter outputFile;
    outputFileName = "D:\\cdoutput.txt";
    outputFile = new PrintWriter(new FileWriter(outputFileName,true));
    int loopTest;
    do
    String numStr = JOptionPane.showInputDialog("Please enter Index number");
    int number = Integer.parseInt(numStr);
    cC.setIndexNumber(number);
    numStr = JOptionPane.showInputDialog("Please enter cd name");
    number = Integer.parseInt(numStr);
    cC.setCdName(number);
    String message = cC.toString() +
    "\nYour input is: ";
    JOptionPane.showMessageDialog(null, message);
    outputFile.println(numStr + "");
    loopTest = JOptionPane.showConfirmDialog(null,"Do another?","",0,1);
    while (loopTest == 0);
    outputFile.close();

    class findCD implements ActionListener
           public void actionPerformed(ActionEvent event)
                try
                     writeCd();
                } catch(Exception e){
                                        e.printStackTrace();
      public void writeCd() throws Exception
          String outputFileName;
          PrintWriter outputFile;
          outputFileName = "D:\\cdoutput.txt";
    outputFile = new PrintWriter(new
    (new FileWriter(outputFileName,true));
             int loopTest;
             do
    String numStr =
    umStr = JOptionPane.showInputDialog("Please enter
    Index number");
             int number = Integer.parseInt(numStr);
             cC.setIndexNumber(number);
    numStr = JOptionPane.showInputDialog("Please
    "Please enter cd name");
             number = Integer.parseInt(numStr);
             cC.setCdName(number);
             String message = cC.toString() +
                              "\nYour input is: ";
             JOptionPane.showMessageDialog(null, message);
            outputFile.println(numStr + "");
    loopTest =
    pTest = JOptionPane.showConfirmDialog(null,"Do
    another?","",0,1);
             while (loopTest == 0);
           outputFile.close();
        }That should work. This also assumes that the method writeCd is in the class findCD.

  • Can someone please help with this code and what it means? Interval Since Last Panic Report:  6395213 sec Panics Since Last Report:          1 Anonymous UUID:                    8AEBAB22-1943-48B3-8D30-E4D07CCDEEA0  Tue Mar 18 13:30:13 2014 Machine-check c

    Interval Since Last Panic Report:  6395213 sec
    Panics Since Last Report:          1
    Anonymous UUID:                    8AEBAB22-1943-48B3-8D30-E4D07CCDEEA0
    Tue Mar 18 13:30:13 2014
    Machine-check capabilities (cpu 3) 0x0000000000000006:
    family: 6 model: 15 stepping: 6 microcode: 198
    Intel(R) Xeon(R) CPU            5160  @ 3.00GHz
    6 error-reporting banks
    Machine-check status 0x0000000000000005:
    restart IP valid
    machine-check in progress
    MCA error-reporting registers:
    IA32_MC0_STATUS(0x401): 0x1000000020000000 invalid
    IA32_MC1_STATUS(0x405): 0x0000000000000000 invalid
    IA32_MC2_STATUS(0x409): 0x0000000000000000 invalid
    IA32_MC3_STATUS(0x40d): 0x0020000000000000 invalid
    IA32_MC4_STATUS(0x411): 0x0000000000000011 invalid
    IA32_MC5_STATUS(0x415): 0xb200001080200e0f valid
    MCA error code:            0x0e0f
    Model specific error code: 0x8020
    Other information:         0x00000010
    Status bits:
      Processor context corrupt
      Error enabled
      Uncorrected error
    panic(cpu 2 caller 0x2cf3cc): "Machine Check at 0x002d3432, trapno:0x12, err:0x0," "registers:\n" "CR0: 0x80010033, CR2: 0x103dd000, CR3: 0x00100000, CR4: 0x00000660\n" "EAX: 0x00000000, EBX: 0x000000be, ECX: 0x6241b000, EDX: 0x00000001\n" "ESP: 0x6f853c58, EBP: 0x6f853c58, ESI: 0x00000000, EDI: 0x827a6b3c\n" "EFL: 0x00000016, EIP: 0x002d3432\n"@/SourceCache/xnu/xnu-1699.32.7/osfmk/i386/trap_native.c:258
    Backtrace (CPU 2), Frame : Return Address (4 potential args on stack)
    0x6853cf38 : 0x2203de (0x6b08cc 0x6853cf58 0x229fb0 0x0)
    0x6853cf68 : 0x2cf3cc (0x6bde94 0x6bdfc8 0x2d3432 0x12)
    0x6853d0d8 : 0x2cf409 (0x6853d110 0xde 0x6bdfc8 0x1)
    0x6853d0f8 : 0x2e6182 (0x6853d110 0x0 0x0 0x0)
    0x6f853c58 : 0x2d381e (0x20 0x7fffffff 0x6f853c88 0x29701be)
    0x6f853c68 : 0x29701be (0x684b6100 0xffffffff 0x6f853cb8 0x9d8e800)
    0x6f853c88 : 0x297028b (0x684b6100 0xffffffff 0x7fffffff 0x827aa38d)
    0x6f853cb8 : 0x296864f (0x684b6100 0x827aa38d 0xbe 0xffffffff)
    0x6f853d58 : 0x29699fe (0x827aa38d 0xbe 0x3 0x0)
    0x6f853de8 : 0x2d0cde (0xffffffff 0x7fffffff 0x6f853e08 0x2cd4ca)
    0x6f853e08 : 0x22d3e5 (0x684c5000 0x827a6711 0xbe 0x684c5de0)
    0x6f853e48 : 0x22e1c0 (0xd58c7f0 0x684c5000 0x0 0x0)
    0x6f853e98 : 0x22f6c2 (0xd58c80c 0x2 0x12 0xd7c0e00)
    0x6f853ef8 : 0x22f821 (0x2150f0 0x0 0x0 0xd58c7f0)
    0x6f853f18 : 0x21505d (0x2150f0 0x7000006 0xc00 0xffffffff)
    0x6f853f48 : 0x21b385 (0xede8f28 0x7000006 0xc00 0xffffffff)
    0x6f853f98 : 0x2b7bb7 (0xd4c9954 0x7fff 0xd4c9984 0x8)
    0x6f853fc8 : 0x2e60c7 (0xd4c9950 0x0 0x10 0xd4c9950)
         Kernel Extensions in backtrace:
            com.apple.driver.AppleIntelCPUPowerManagement(195.0)[D1550426-D346-4805-A777-06 63C69080DA]@0x2966000->0x298ffff
    BSD process name corresponding to current thread: iTunes
    Mac OS version:
    11G63
    Kernel version:
    Darwin Kernel Version 11.4.2: Thu Aug 23 16:26:45 PDT 2012; root:xnu-1699.32.7~1/RELEASE_I386
    Kernel UUID: 859B45FB-14BB-35ED-B823-08393C63E13B
    System model name: MacPro1,1 (Mac-F4208DC8)
    System uptime in nanoseconds: 818233088876
    last loaded kext at 91751914186: com.apple.driver.AppleHWSensor          1.9.5d0 (addr 0x2990000, size 28672)
    last unloaded kext at 226546974280: com.apple.driver.CSRHIDTransitionDriver          4.0.8f17 (addr 0x21cd000, size 12288)
    loaded kexts:
    com.parentalctrl.kext.filter          3.8.1
    com.logmein.driver.LogMeInSoundDriver          1.0.3
    com.apple.driver.AppleHWSensor          1.9.5d0
    com.apple.driver.AppleUpstreamUserClient          3.5.9
    com.apple.driver.AppleMCCSControl          1.0.33
    com.apple.driver.AppleHDA          2.2.5a5
    com.apple.driver.AudioAUUC          1.59
    com.apple.GeForce7xxx          7.0.4
    com.apple.driver.AppleUSBDisplays          323.3
    com.apple.iokit.IOUserEthernet          1.0.0d1
    com.apple.iokit.IOBluetoothSerialManager          4.0.8f17
    com.apple.Dont_Steal_Mac_OS_X          7.0.0
    com.apple.driver.AppleMCEDriver          1.1.9
    com.apple.driver.Apple_iSight          4.0.1
    com.apple.driver.AudioIPCDriver          1.2.3
    com.apple.driver.ApplePolicyControl          3.1.33
    com.apple.driver.ACPI_SMC_PlatformPlugin          5.0.0d8
    com.apple.driver.AppleLPC          1.6.0
    com.apple.filesystems.autofs          3.0
    com.apple.driver.CSRUSBBluetoothHCIController          4.0.8f17
    com.apple.iokit.SCSITaskUserClient          3.2.1
    com.apple.driver.AppleRAID          4.0.6
    com.apple.AppleFSCompression.AppleFSCompressionTypeDataless          1.0.0d1
    com.apple.AppleFSCompression.AppleFSCompressionTypeZlib          1.0.0d1
    com.apple.BootCache          33
    com.apple.driver.XsanFilter          404
    com.apple.iokit.IOAHCIBlockStorage          2.1.0
    com.apple.driver.AppleFWOHCI          4.9.0
    com.apple.driver.AppleAHCIPort          2.3.1
    com.apple.driver.AppleIntelPIIXATA          2.5.1
    com.apple.driver.AppleIntel8254XEthernet          2.1.3b1
    com.apple.driver.AppleEFINVRAM          1.6.1
    com.apple.driver.AppleUSBHub          5.1.0
    com.apple.driver.AppleUSBUHCI          5.1.0
    com.apple.driver.AppleUSBEHCI          5.1.0
    com.apple.driver.AppleACPIButtons          1.5
    com.apple.driver.AppleRTC          1.5
    com.apple.driver.AppleHPET          1.7
    com.apple.driver.AppleSMBIOS          1.9
    com.apple.driver.AppleACPIEC          1.5
    com.apple.driver.AppleAPIC          1.6
    com.apple.driver.AppleIntelCPUPowerManagementClient          195.0.0
    com.apple.nke.applicationfirewall          3.2.30
    com.apple.security.quarantine          1.4
    com.apple.security.TMSafetyNet          8
    com.apple.driver.AppleIntelCPUPowerManagement          195.0.0
    com.apple.driver.AppleBluetoothHIDMouse          175.9
    com.apple.driver.AppleHIDMouse          175.9
    com.apple.driver.IOBluetoothHIDDriver          4.0.8f17
    com.apple.driver.AppleSMBusController          1.0.10d0
    com.apple.driver.DspFuncLib          2.2.5a5
    com.apple.nvidia.nv40hal.G7xxx          7.0.4
    com.apple.NVDAResman.G7xxx          7.0.4
    com.apple.iokit.IOFireWireIP          2.2.5
    com.apple.iokit.IOSurface          80.0.2
    com.apple.iokit.IOSerialFamily          10.0.5
    com.apple.driver.AppleHDAController          2.2.5a5
    com.apple.iokit.IOHDAFamily          2.2.5a5
    com.apple.iokit.IOAudioFamily          1.8.6fc18
    com.apple.kext.OSvKernDSPLib          1.3
    com.apple.driver.AppleGraphicsControl          3.1.33
    com.apple.iokit.IONDRVSupport          2.3.4
    com.apple.iokit.IOGraphicsFamily          2.3.4
    com.apple.driver.AppleSMC          3.1.3d10
    com.apple.driver.IOPlatformPluginLegacy          5.0.0d8
    com.apple.driver.IOPlatformPluginFamily          5.1.1d6
    com.apple.kext.triggers          1.0
    com.apple.driver.AppleUSBBluetoothHCIController          4.0.8f17
    com.apple.iokit.IOBluetoothFamily          4.0.8f17
    com.apple.driver.AppleUSBHIDKeyboard          160.7
    com.apple.driver.AppleHIDKeyboard          160.7
    com.apple.iokit.IOUSBHIDDriver          5.0.0
    com.apple.driver.AppleUSBMergeNub          5.1.0
    com.apple.driver.AppleUSBComposite          5.0.0
    com.apple.iokit.IOSCSIMultimediaCommandsDevice          3.2.1
    com.apple.iokit.IOBDStorageFamily          1.7
    com.apple.iokit.IODVDStorageFamily          1.7.1
    com.apple.iokit.IOCDStorageFamily          1.7.1
    com.apple.iokit.IOATAPIProtocolTransport          3.0.0
    com.apple.iokit.IOSCSIArchitectureModelFamily          3.2.1
    com.apple.iokit.IOFireWireFamily          4.4.8
    com.apple.iokit.IOAHCIFamily          2.0.8
    com.apple.iokit.IOATAFamily          2.5.1
    com.apple.iokit.IONetworkingFamily          2.1
    com.apple.iokit.IOUSBUserClient          5.0.0
    com.apple.driver.AppleEFIRuntime          1.6.1
    com.apple.iokit.IOUSBFamily          5.1.0
    com.apple.iokit.IOHIDFamily          1.7.1
    com.apple.iokit.IOSMBusFamily          1.1
    com.apple.security.sandbox          177.11
    com.apple.kext.AppleMatch          1.0.0d1
    com.apple.driver.DiskImages          331.7
    com.apple.iokit.IOStorageFamily          1.7.2
    com.apple.driver.AppleKeyStore          28.18
    com.apple.driver.AppleACPIPlatform          1.5
    com.apple.iokit.IOPCIFamily          2.7
    com.apple.iokit.IOACPIFamily          1.4
    Model: MacPro1,1, BootROM MP11.005C.B08, 4 processors, Dual-Core Intel Xeon, 3 GHz, 5 GB, SMC 1.7f10
    Graphics: NVIDIA GeForce 7300 GT, NVIDIA GeForce 7300 GT, PCIe, 256 MB
    Memory Module: DIMM Riser A/DIMM 1, 512 MB, DDR2 FB-DIMM, 667 MHz, 0x802C, 0x39485446363437324A592D36363742344433
    Memory Module: DIMM Riser A/DIMM 2, 512 MB, DDR2 FB-DIMM, 667 MHz, 0x802C, 0x39485446363437324A592D36363742344433
    Memory Module: DIMM Riser A/DIMM 3, 2 GB, DDR2 FB-DIMM, 667 MHz, 0x8319, 0x4D4B435333385554412D4944542020202020
    Memory Module: DIMM Riser A/DIMM 4, 2 GB, DDR2 FB-DIMM, 667 MHz, 0x8319, 0x4D4B435333385554412D4944542020202020
    Bluetooth: Version 4.0.8f17, 2 service, 18 devices, 1 incoming serial ports
    Network Service: Ethernet 1, Ethernet, en0
    PCI Card: NVIDIA GeForce 7300 GT, sppci_displaycontroller, Slot-1
    Serial ATA Device: ST3250824AS  Q, 250.06 GB
    Serial ATA Device: SAMSUNG HD501LJ, 500.11 GB
    Serial ATA Device: WDC WD10EADS-00M2B0, 1 TB
    Serial ATA Device: WDC WD10EADS-00M2B0, 1 TB
    Parallel ATA Device: SONY    DVD RW DW-D150A
    USB Device: hub_device, apple_vendor_id, 0x911d, 0xfd500000 / 3
    USB Device: Keyboard Hub, apple_vendor_id, 0x1006, 0xfd520000 / 5
    USB Device: Apple Keyboard, apple_vendor_id, 0x0220, 0xfd522000 / 6
    USB Device: Apple Cinema Display, apple_vendor_id, 0x921d, 0xfd530000 / 4
    USB Device: USB2.0 Hub, 0x05e3  (Genesys Logic, Inc.), 0x0608, 0xfd400000 / 2
    USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8206, 0x5d200000 / 2
    FireWire Device: built-in_hub, 800mbit_speed
    FireWire Device: iSight, Apple Computer, Inc., 200mbit_speed
    FireWire Device: unknown_device, unknown_speed

    Kernel panic, machine check, uncorrected error correlates very strongly with RAM memory errors.
    Time for a Memory upgrade.

  • Trying to update photoshop and repeatedly get error code U44M1P7, can anyone please help resolve this?

    Trying to update photoshop and repeatedly get error code U44M1P7, can you please help resolve this?

    JJMack, Thanks for the info. Let this old man digest it and see if I can put the info into action. I'll give you a feedback. Thanks for your help in this matter. I am not a tech savvy person. 
    Rueben Rueben D. Olivas Home Ph:  1-671-969-2452
    Cell Ph:  1-671-747-2453La Luz Photography
    Email: [email protected]/Guam Firehouse Cook: http://guamfirehousecook.blogspot.com/BBQGuam: http://bbqguam.blogspot.com/My Photostream: http://ruebenolivas.megashot.net/photostream

  • Search criteria is not working in Responsible Group field in sap crm could you please help me this how to achieve.

    search criteria is not working in Responsible Group field in sap crm could you please help me this how to achieve.I have writen code on EH_ONSEARCH .as per below...what changess i need to do..and through partner function and adding the selection params please send the sample .
    code. partner funtction - ZRG DATA :
    DATA : lv_partner_fct type .
    types: begin of ty_resp,
           partner    type but000-partner,
           name_last  type but000-name_last,
           name_first type but000-name_first,
           mc_name1   type but000-mc_name1,
           mc_name2   type but000-mc_name2,
           end of ty_resp.
    DATA: lv_resp_bp type STANDARD TABLE OF ty_resp INITIAL SIZE 0,
           lw_resp_bp type ty_resp.
    IF lv_attr_name = 'Rgroup'.
    lr_entity->get_property_as_value( EXPORTING iv_attr_name = if_crm_srqm_uiu_const=>gc_attr_low
                                       IMPORTING ev_result = lv_low ).
    IF lv_low IS INITIAL.
    SELECT partner
           name_last
           name_first
           mc_name1
          mc_name2
    FROM but000 INTO table lv_resp_bp
    WHERE mc_name2 = lv_low and bu_group = '0010'.
    loop at lv_resp_bp into lw_resp_bp.
        lv_low = lw_resp_bp-mc_name2.
      lr_query_service2->add_selection_param( iv_attr_name = 'Rgroup'
                                                iv_sign = lv_sign
                                                iv_option = lv_option
                                                iv_low = lv_low
                                                iv_high = lv_high ).
      ENDLOOP.
    if lv_partner_fct = 'ZRG'.
      lr_entity = lr_iterator->get_next( ).
    CONTINUE.
    ENDIF.
    lv_attr_name = 'BU_PARTNER'.
    ENDIF.

    <b>You can acheive   this .... first by creating the search help exit    ... by  creating the maintaince  view   then   using it in the   Creation of the search help </b> ...
    see the link for attaching the view   to the serach help .
    <a href="http://">http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_elementary.htm</a>
    reward  points if it is usefull...
    Girish

  • Please help 'Translate' These codes from AS2 to AS3 for me

    Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
    toc    loadText = new LoadVars();
        loadText.load("Curie.txt");
        loadText.onLoad = function(success) {
            if (success) {
                // trace(success);
                Curie.html = true;
                Curie.htmlText = this.Curie;
    Please translate it for me, i need it ASAP thanks
    Kenneth

    Thank you for helping me
    Kenneth
    Date: Thu, 15 Oct 2009 05:49:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: Please help 'Translate' These codes from AS2 to AS3 for me
    Take a look at that:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
    There is a LoadVars section on that.
    There is also a tutorial here:
    http://www.republicofcode.com/tutorials/flash/as3externaltext/
    Cheers,
    CaioToOn!
    >

  • When trying to verify the email address, I get the following message. Please help. This email address is already in use or you may already have an Apple ID associated with this email address. Please try again or sign in using your existing Apple ID.

    When trying to verify the email address, I get the following message. Please help. This email address is already in use or you may already have an Apple ID associated with this email address. Please try again or sign in using your existing Apple ID.

    Me too. I try to verify and i get the same message.
    I've created 3 alternate e-mail addresses and tried creating new accounts.
    Same Result!
    This is bullsh!t. How the **** can all 4 of my attempts result in the same freakin error???

  • I just bought a new iPhone and accidentally backed it up with my old iPhone backup, I do not want this. I lost everything on my new phone and I need it back. PLEASE HELP! This includes pictures and texts, etc.

    I just bought a new iPhone and accidentally backed it up with my old iPhone backup, I do not want this. I lost everything on my new phone and I need it back. PLEASE HELP! This includes pictures and texts, etc.

    So just to be clear, when you say "just bought" how long ago was that? Is it on this new iPhone that you had pictures, texts, etc that you want? Were you backing up to iCloud or onto iTunes?
    This may not help for everything but if you go to iCloud.com and log in, are you able to find your pictures there?

  • Every time I sync my Iphone 5c(with ios 8) to Itunes, it 1. deletes all of my purchased music 2. deletes all of my album artwork 3. replaces all of my deleted songs. please help! this is driving me crazy!

    Every time I sync my Iphone 5c(with ios 8) to Itunes, it 1. deletes all of my purchased music 2. deletes all of my album artwork 3. replaces all of my deleted songs. please help! this is driving me crazy! It syncs 100+ songs, when I only want to sync 1! I'm running Itunes 11.3.1.2

    After having experienced similar problems and having it back to work, I have a few suggestions:
    - Try to find out if the syncing stops at a particular track or song. That might - out of the blue - have gotten corrupted in one way or another. Since that song will not be on the iPod, iTunes will try over and over to put it on and crash in one way or another;
    - reformat the iPod as described in the iTunes 9 crash-thread. It takes time (at first it seems to do nothing, but that is because the green bar is moving with very small steps);
    HTH

  • Please Help on this

    Hi Experts,
        I have schema which has to be implemented in SAP BI 7.0.Schema contains one Fact Table & three Dimension tables.It is snowflake schema.
    Assume Fact table as F & Dimension  tables as D1,D2,D3.The Schema is as follows.
    F---->D1--->D2---->D3
    Now i have created navigation attribute from D1 to D2 & D2 to D3 Then i have created a infocube having  facts & D1 attribute.
    So when i drag the infoObject from D1 having navigation attributes to D2 & from D2 to D3 iam unable to get D3 information.
    Please can any one suggest me how to get D3 level of information in report Or how to accesss the facts & D3 level information .
    Please Help on this
    Thanks & Regards
    Sameer Khan

    Hi Sameer,
    Your question is not clear.
    Regards,
    Sagar

  • I was trying to set Adobe Reader 11 as default PDF viewer on my client PCs, Please help me this. My server is windows 2012 R2 and client PCs are Windows 8.1

    I was trying to set Adobe Reader 11 as default PDF viewer on my client PCs, Please help me this. My server is windows 2012 R2 and client PCs are Windows 8.1

    Hi Krisis,
    I have found a forum where similar query was answered. Hope this helps.
    http://www.loginvsi.com/forum/support-v4/857-adobe-reader-xi-not-set-as-default-pdf-viewer -in-server-2012-r2-rds
    Regards,
    Anoop

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • HT5312 i forgot my secret question, please help me this problem. Thanks

    I forgot my secret question, please help me this problem. Thanks

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    And/or see the  More Like This  section on the right.

  • Please help in this

    Hi
    Please help with this:
    How to know if string buffer doent contain anything:
    I am getting stringoutofbounds exception..
    StringBuffer myString=new StringBuffer(" ");
    if(myString.toString()!=" ")
         int i=myString.lastIndexOf(",");
         myString.deleteCharAt(i).toString());
         }

    If you want to compare the equivalence of two String datatypes, use the "equals()" method. The technique you are using, the equality operator '!=', will compare not the semantic value of the string representation, but rather the value of the object reference of that string. So in your example, ( myString.toString() != "" ) will always be true, even if the StringBuffer is instantiated with an empty string because the two sides of the operator refer to different objects.
    Use instead ..
    if ( !myString.toString().equals(""))

  • My Canon MP620 appears to be connected, yet every time I try to print something, it says error.  I have tried to unplug and track the error, but I cannot figure out why. Please help! this is such an inconvenience!

    My Canon MP620 appears to be connected, yet every time I try to print something, it says error.  I have tried to unplug and track the error, but I cannot figure out why. Please help! this is such an inconvenience!

    What Mac model? What Mac OS version?
    FYI, this forum is for Apple hardware made before 1999.

Maybe you are looking for