Output error help

How do i correct the error in my code below. Also, i want to add 1 things to my output, before it preforms the insertion sort, so i can show the person who is seeing the output that these r the numbers before the sort, & these r after:
1) Original Values = (the values stored in int[] no)
thanks.
public class Sort
     public static void insSort (int[] num)
          for (int index = 1; index < num.length; index++)
               int key = num[index];
               int pos = index;
               while (pos > 0 && num[pos-1] > key)
                    num[pos] = num[pos-1];
                    pos--;
               num[pos] = key;
     public static void insSort (Comparable[] obj)
          for (int index = 1; index < obj.length; index++)
               Comparable key = obj[index];
               int pos = index;
               while (pos > 0 && obj[pos-1].compareTo(key) > 0)
                    obj[pos] = obj[pos-1];
                    pos--;
               obj[pos] = key;
     public static void main(String[] args)
               int[] no = {12, 22, 99, 34, 5, 16, 44, 65, 11};
               insSort(no);
               for (int index = 0; index < no.length; index++);
               System.out.println ("Insertion Sort = " + "\n");
               System.out.println (no[index] + " ");

try this
public class Sort{
   public static void insSort (int[] num){
      for (int index = 1; index < num.length; index++){
         int key = num[index];
         int pos = index;
         while (pos > 0 && num[pos-1] > key){
            num[pos] = num[pos-1];
            pos--;
         }// while.
            num[pos] = key;
         }// for.
      }// insSort.
//======================================================================
   public static void insSort (Comparable[] obj){
      for (int index = 1; index < obj.length; index++){
         Comparable key = obj[index];
         int pos = index;
         while (pos > 0 && obj[pos-1].compareTo(key) > 0){
            obj[pos] = obj[pos-1];
            pos--;
         }// while.
         obj[pos] = key;
      }// for.
   }// insSort.
//======================================================================
   public static void main(String[] args){
      int[] no = {12, 22, 99, 34, 5, 16, 44, 65, 11};
      System.out.print ("Before Sort = {");
      for (int index = 0; index < no.length; index++){
         System.out.print (no[index] + ", ");
      }// for.
      System.out.print ("}");
      insSort(no);
      System.out.print ("\n\nAfter Sort = {");
      for (int index = 0; index < no.length; index++){
         System.out.print (no[index] + ", ");
      }// for.
      System.out.print ("}");
   }// main.
//======================================================================
}// Sort.original compile error was the last System.out.print statement was out side the for loop.
cheers
jamie

Similar Messages

  • I had a problem with the hard disk on a 2010 macbook pro. Replaced the hard disk with an Hitachi 1TB and when I tried to erase and format It fails with input/output error. Any help much appreciated!

    I had a problem with the hard disk on a 13" 2010 macbook pro. Replaced the hard disk with an Hitachi 1TB disk but when I tried to erase and format, it fails with input/output error and at other times saying unable to allocate memory. Any help much appreciated!

    Zap the PRAM and Reset the SMC, then try again.

  • Help -- backup data with disk utility, input/output error.

    My problem started when my MacBook Pro computer (with OsX) froze.  When I restarted, the startup screen stayed on for a long time.  Now, the startup screen stays on for a few seconds and then shuts off.  I do NOT have a recent backup of my data.  I have tried the following:
    Went onto the recovery partition, used Disk Utility.  When I verified the disk, it said it needed repair.  When I tried to repair the disk, it said it could not be repaired.
    I then tried to copy a disk image of the hard drive onto my external hard drive, but it says there is an "input/output error" and won't allow it.  How else can I backup files on my computer at this point?

    Had issue partitioning 2TB my passport drive, got input/output error while using disk utility.
    Here is what I did to get my external disk back
    In Disk Utility
    1) Try to use erase option first, it failed
    2) Try to partition the disk, failed as well.
    3) Then try erase option again, then ...   it worked !!

  • Failed to execute default file manager (input/output error) After Firefox Reset? [Any more help? you guys/gals rule!]

    after resetting firefox it seems I cant open anything from the menu as i get the above error msg.

    Are you using ubuntu? [http://askubuntu.com/questions/42682/failed-to-execute-default-file-manager-input-output-error]

  • External Hard Drive Input/Output error

    I recently started having problems with an external hard drive setup that I did not have problems with prior to upgrading to 10.5.5 and trying to setup the drive to be compatible with Time Machine.
    The hard drive enclosure that I have has 2 bays for two SATA drives. I have used this enclosure without any problems until I tried to get 1 drive to act as the backup drive for Time Machine and the other to be storage. I formatted them using Drive Genius. I used the option for GUILD or GUIL which it said was the better format for using with Time Machine.
    The first problem I ran into since upgrading and reformatting the drives is I got an "input/output" error the first couple times I connected the drive via USB to my Mac. I could still use the drives but I got weird errors every once in a while like "input/output error" or "device was not ejected properly" even though the device had not been unplugged.
    Now the drives will not mount using OS 10.5.5. The drives show up when I open Disk Utility, but I cannot get them to mount. I have ran Disk Utility First Aid, and it says the drives are fine. There is one error that shows up when I run the "Repair Disk" feature. It reads "Invalid content in Journal". But Disk Utility also says "The volume was repaired successfully".
    I have seen some posts when I do a search in google about this issue and it seems this is a known issue. Every suggestion I see says to insert your Tiger DVD and reformat the drive using that and the problem will be solved. The only problem with that is I have a lot of important files on the drive that I cannot lose. I had the files backed up until I moved them to the new drive a while back. Now I do not have a backup because I was in the process of switching to bigger drives and erased the old drives after doing so because everything was working fine.
    I am hoping someone out there may have some suggestions (other than erasing the drive) to get my dives to mount so I can transfer the data off to another drive and reformat after.
    Thanks,
    Paul Rugg

    Thanks for the suggestion.
    Do you think that would work better than Drive Genius? I bought Drive Genius 2 and it does not even see the drives when they are plugged in unlike Disc Utility which can see the drives but cannot mount either one.
    Maybe this following post I made to a different questions may help. The data on the drive is other buying another program for if it will work. I think my next step may be to go over to a friends place and try to mount the drives on his computer and transfer stuff off if they connect.
    text below posted to other question relating to external hard drive problem.
    I have recently had the same mounting issue with my new external hard drive. I just purchased a new 750Gb Western Digital Sata drive and got everything transfered over to it. Immediately, I got an error saying that the drive had been ejected incorrectly even though it was still plugged in. I was a little curious. I restarted the computer (hard drive still plugged in via USB 2.0) and the drive showed up just fine. I plugged another 250Gb drive into the same case (2 bays) and the 250GB drive showed up just fine.
    Well, I then noticed there was an OS upgrade available when I ran Software update so i ran it and when I rebooted the drives were gone. I can see the drives in Disc Utility, but they will not mount. Drive Genius cannot see either disc. Disc Utility says I need to repair the drives, but when I do it says they are fixed but they don not mount.
    The problem really seems to be related to mounting USB external drives. I got ahold of 2 seperate external firewire hard drives and one shows up just fine while the other has the same problem (both work on other systems. I would try wiping the drives and reformatting but ALL MY stuff is on them and not everything has been backed up. Yuck! I have not tried connecting my hard drive to another Mac yet.
    The drives being used are #1 Maxtor Maxline Plus II 250GB SATA/150 HDD 1.5b/s 7Y250m00654ra
    and #2 Western Digital WD7500AACS WD Caviar GP Green Power drive.
    I have another post similar to this and I have not received any feedback, but I have been doing my own searching and have found similar posts on the net.
    Anybody have any clue what might be going on here? It really seems to be related to my upgrade.

  • Input/output error when copying a DVD

    I created A DVD some time ago using Roxio.  It plays in DVD Player on my Mac Pro, but I can't create a .dmg using Disk Utility.  I always get "Input/Output error".  I got the same result on my wife's newer Apple. I tried to Restore it but can't, and Verification shows no problems that I can see.  I am able to copy DVDs created on Final Cut Express just fine.  Any suggestions to help me create copies of an old DVD I love?

    I just figured out how to get around the problem.  Download Burn and use it to burn the VIDEO_TS file to a new disk.  It must be something that Apple adds to make it hard to copy DVDs made from non-Apple software.

  • I'm trying to backup a my harddrive with disk utility but I'm getting an error  Unable to create Backup.dmg" (input/output error). Is there any other way to save my data? I believe my hard drive is failing or corrupt file. I can't boot up. Grey screen

    I'm trying to backup a my hard drive with disk utility but I'm getting an error  Unable to create Backup.dmg" (input/output error). Is there any other way to save my data? I believe my hard drive is failing or corrupt file. I can't boot up. Grey screen and spinning wheel. I've tried everything https://discussions.apple.com/message/20580424#20580424
    any help will be greatly appreciated.

    Check here. Also have you done a TimeMachine back up?
    http://support.apple.com/kb/TS2570

  • External Hard Drive not Readable & Input/Output Error?

    I was using my OWC 300gb external hard drive for a while and it's worked great. I had a bunch of files on it, but I recently transferred everything to another external HD I have, which worked fine, so I could erase this 300gb one. I can't remember what happened, but somehow my Macbook doesn't recognize this hard drive. I think erased everything and then unplugged it without ejecting it first. Anyways, nothing is on the the drive anymore and I get this error message:
    "The disk you inserted was not readable by your computer"
    This pops up when I restart my Macbook. When I try to use Disk Utility, it greys everything out on the partition and Disk Repair tabs. On the 'Erase' tab, it will allow me to select Erase, but then gives me the error:
    "Input/Output error"
    Does anyone know how to get my Macbook to see my drive (so I can start to partition it)? For some reason only Disk Utility acknowledges it's there, Finder won't.
    Anyone have any tips of what it is or what I can try? I did try to use my OS discs booting up holding C, but that doesn't work either.

    Hi there. Everyone is saying on these forums that the hard drive is failing...suck. I went and bought a new when I got input/output error and found that the new one showed the same input output error, making it impossible to partition the disk. Then the guy in the apple service center told me the new one was bad too, after having seen the code that came up related to my new scorpio 250 GB drive. Instead of sending it back, I took it out and installed the old one..however this time with a slihtly more of pressure on the tape holding down the hard drive cable between the hard drive and the circuit board. Amazingly, this time it didn't even show any hard drive at all! Then I understood what was wrong. It was exactly what was indicated an "input/output errror"! ..the cable was broken. I bought a new cable, well the Powerbookmedic sold it as new but it was an old working one that arrived. Immediately, after change of cable the old hard drive and now also the new 250 GB works perfectly! I remember that some interesting symptoms prior to all hard drive problems appeared, such as not being able to start up properly, strange blue screens, flipping question marks etc. I remember that shaking the comp occasionally worked to get it going. No wonder, shaking occasionally made it work and i believe the damaged cable maybe changed position and started conducting. The cable is very sensitive and probably should not be taped down so hard as the first service center guy at apple had done with mine when he fixed it the comp a few years ago. Polymers/plastics bent heavily become fragile/brittle with time and are specially sensitive under pressure/bent. Note that my old damaged cable still conducted and showed the hard drives but didn't work fully. I hope this will help someone, it took me 2 month to figure out..

  • External HD - Input/Output Error

    I had external drive that was not mounting or appearing on Disk Utility. The drive was out of warranty so I went ahead and changed the casing.
    1.The drive appears on Disk Utility but still does not mount. DU only shows the root and not the volume.
    2.Connecting it via USB tells me the drive is 298GB and appears as Maxtor 5000DV v0.1.00.00 Media. I connect it via Firewire 400 and it DU shows it as 128GB Maxtor.
    Any help on what's going on here? DU also won't let me First Aid, Erase, or anything else on it. After I try to Erase it,Partition it, or anything it gives me "Input/Output Error".
    10.5.2
    Maxtor External (Actually a Seagate inside)
    G5
    Thanks for any help!

    Adding:
    What is the point of "Restore" and how is it used exactly?
    Thanks!

  • External Drive Disk Erase Failed with the Error Input/Output Error

    I have 2 hard drives in an external FW800 enclosure that I am unable to format. When I go to initialize the drives in Disk Utility, I get the following error message: "Disk Erase failed with the error: Input/output error."
    The drives show up in Disk Utility, but I can't repair them (that option is grayed out). Disk Utility correctly ID's the manufacturer of the drives (Maxtor), their size (200gb each), so it's obviously seeing that the drives are there. But it won't let me format them.
    The drives are new, by the way; they don't have any data/files on them. I have Disk Warrior, but the drives don't show up there to be repaired -- probably because they aren't formatted yet.
    After looking at other posts, I tried switching the jumper settings around on the drives -- from Master/Slave to cable select and back again, but it didn't help. I also tried doing a zero erase (even though the drives are new), zapping the PRAM -- again, no help.
    One question I had is whether this could be a bad FW800 cable? The cable is new -- it came with the enclosure, which is an OWC Dual FW 800 enclosure. Other than that, does anyone have any other thoughts about what's causing this? Any help would be greatly appreciated.
    Matthew

    SOLUTION!!!!
    I had the exact same problem. I have the original 20 GB hard drive that came in my Powerbook G4 550MHz and a couple of years ago I traded up for a 60 GB drive and bought a FW/USB enclosure for my original drive to use it to backup my important files. I hadn't backed up in over a year (shame on me!) and I decided maybe I should erase the drive and start from scratch. It was connected via USB.
    At that point DiskUtility gave me the exact same Input/Output error. I tried partitioning the drive into 1 or more partitions but came up with the same error. I couldn't figure out what was wrong so I decided to startup in OS 9.2.2, I did that and let it start up, then plugged in the hard drive and it gave me the standard "This disk is unrecognizable, do you want to eject or erase?" so I clicked Initalize. It worked!
    Just make sure you choose the MacOS Extended option when initializing out of OS 9 (instead of the MacOS Standard option) so it can be read and viewed in OS X.
    If your computer is too new to be able to boot from an OS 9 folder on your drive or an OS 9 CD, then see if a friend or a local library has older computers that are running OS 9 or can boot from it. If not let me know and you can send me your drive and I'll reformat it.
    Kind of crazy...I haven't used the OS 9 partition on my HD in YEARS...was even thinking about erasing it since I don't use any Classic applications anymore...good thing I didn't!
    Nick
    Powerbook G4 550Mhz   Mac OS X (10.4.6)  

  • Hi, I have a hard disk failure so to recover my data I am using disk utility to restore the data on an external drive while booting from a second external hard drive. When I perform the operation it gives me an input/output error and stops. Any tips?

    Hi, I have a hard disk failure so to recover my data I am using disk utility to restore the data on an external drive while booting from a second external hard drive. When I perform the operation and after having selected both my destination and source drives, the operation begins but soon fails due to input/output error. If I try to create an image of the drive it gives me the same error message. Any help would be much appreciated.

    Disk Utility only creates a image of the drive, so it's no help getting exactly what you want, which is your files. If the file structure is messed up or the drive is failing then it's no help.
    If you have a external boot drive and you can't access the internal non-booting drive though the typical Finder and windows to transfer your files via drag and drop methods, then you need to install Data Rescue on the external boot drive and it will do as best as it can to recover your files. (works on non-encrypted/non-Filevaulted drives only)
    .Create a data recovery/undelete external boot drive
    Are you sure you have hard drive failure, or that OS X isn't merely not booting?
    Because if the drive is working physically, then there is a host of fixes
    ..Step by Step to fix your Mac
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents#/

  • WD External Hard Drive will not format, "Input/Output Error"

    Trying to reformat an old Western Digital external drive, immediate error in Disk Utility "Input/Output Error". Switched USB cords/ports, nothing. Just getting a second opinion before I trash it.
    I know I can probably take out the drive and put it in an external case, but this was just going to be an extra drive for a friend, not worth the $20 for the case.
    Thanks

    I'm getting the same errors from both my USB ports when I try to format a brand new Maxtor 1TB drive.
    I had noticed some strange errors a week ago when Time Machine was reporting an error saying it had failed (this was using a nother external firewire drive). Errors were (not verbatim) "error writing files" & "unknown error".
    I naturally thought there was a prob with the ext drive, so knowing that I had at least a good full back-up on there, bought a new ext drive (larger) to perform a full backup on so I could reformat the firewire drive and utilise it elsewhere - but got errors when I tried to set it up as a Time Machine drive seconds after I took it out of the box.
    I ran "Verify Disk" on my internal macbook HD and it reported some permission errors and mis-reported file sizes and told me to "Repair Disk". I did, and this stated it fixed a few things. Ran Verify again and it still reported some permission errors.
    Now, this leaves me in a sticky spot. I can't format the maxtor external disk in order to manually copy over my disk content, it doesn't even show up in disk Utility or in Finder. I can't perform a Time Machine backup - as it can't see the maxtor disk. I can't do a TM backup on the old Firewire disk - due to the program errors. AND it appears I have permission errors on my internal HD.
    Whatever course of action I take to correct these problems - I would like the knowledge that I have a full backup to restore from if things "head south" while I look to correct the HD permission issues.
    Anyone out there with some REAL SMART ideas that can help me out here ?
    Right now I'll even accept "Half Smart", "Clever" and "**** - Why Didn't I Think Of That" answers !
    S.

  • Restoring .dmg image from external to Mac HD in Disk Utility: "Unable to scan image (Input/output error)"

    Hi guys,
    So I've got a problem with restoring the image backup I did (using Disk Utility) of my 500GB HD on my MBP which was acting weird or maybe even crashed a few months ago. After creating the backup image and putting it on my external device, I installed Mavericks back to see if everything was alright (mainly the HD) and everything seems okay.
    I did try restoring the backup image through disk utility before installing mavericks (thus erasing everything again on the HD) AND after. But nothing..
    The whole process starts fine and then it starts scanning the image when after maybe a good 10-15min in I get a message that says that it was unable to scan the image. I tried verifying the disk(s), everything came out "OK". Also tried scanning it through Images > Scan image for Restore... with the same results.
    While searching I've seen people getting messages like "Unable to scan filename.dmg (Invalid argument)" and "Unable to scan filename.dmg
    (Internal error)" but none have (Input/output error)
    The screen grab is below.
    I also came across something about using terminal/commands but I'm not that savvy with it, especially considering that those there had issues with either mounting or trouble finding the image.
    I've also tried moving the backup image to a different external device 2TB and also the desktop because I read it may have to do with the format of the externals or maybe free space. But THEN I would get a message saying
    "The Finder can't complete the operation because some data in "Mac HD Backup.dmg" can't be read or written. Error code -36"
    Fyi ALL my externals are HFS+/Journaled and the backup image format was compressed.
    I REALLY don't know what to do next. Was it the wrong move to create a dmg image? Have I lost everything? Is there still a way out?
    If anyone can help, THANKS!
    2012 MacBook Pro, Mac OS X (10.9.3)

    Make a "Genius" appointment at an Apple Store, or go to another authorized service provider. You may have to leave the machine there for several days.
    Back up all data on the internal drive(s) before you hand over your computer to anyone. There are ways to back up a computer that isn't fully functional—ask if you need guidance.
    If privacy is a concern, erase the data partition(s) with the option to write zeros* (do this only if you have at least two complete, independent backups, and you know how to restore to an empty drive from any of them.) Don’t erase the recovery partition, if present.
    Keeping your confidential data secure during hardware repair
    Apple also recommends that you deauthorize a device in the iTunes Store before having it serviced.
    *An SSD doesn't need to be zeroed.

  • Disk Utility: Create image fails with input/output error

    Starting to create an image and saving it into an external hard drive (MacOS extended Journaled).
    It starts after less than 60 secs it comes out with an error : Failed to create the image (input/output error)

    If you don't mind I'd like to discourage you from backing up a drive onto a disc image file no matter where you plan to save it. Disc image files can be very problematical when it comes to trying to restore the backup. Furthermore, you cannot boot from a disc image. If the disc image file becomes corrupted then you have no backup.
    I would like to propose that you think about a better way to backup your drive. You can clone the drive to your backup drive. It's easy to do using Disk Utility's Restore feature. A clone backup is not only bootable but you have direct access to all the files on the backup.
    In order to make a bootable clone open Disk Utility. Select Disk Utility Help from the Help menu. Search for +duplicating a disk+. Click on "Duplicating a disk" at the top of the list of articles. Follow the directions.

  • Disk utility 'input/output error' message?

    I am "creating an image" of a DVD using disk utility (prior to making a copy on a blank DVD disk).   Why am I now rec'ing an 'input/output error' message?   I have already copied several other DVDs from the same author (with her permission, they are not copywrited.) w/o a problem.
    What's going on?  original damaged? an incorrect step on my part?  some sort of space problem?  ( I have tons of room on my iMac.)
    Thanks for your help.

    Take a look at Cinematize 2, I've used it with iMovie 06 and iDVD 08. It has several modes of converting the data. One mode is called "lossless".
    For the job you're doing you may prefer to use iMovie 06 instead of iMovie 08 (I would).
    iMovie 06 and iDVD 08 is a terrific combination.
    Your workflow would go something like this.
    Use Cinematize 2 to create a Quicktime file from the DVD.
    http://www.miraizon.com/products/products.html
    Important that file into iMovie 06.
    From iMovie 06, share to iDVD 08 (assuming you want a DVD).

Maybe you are looking for

  • Difference in Creation of BRF+ artifact through API / Workbench

    Hello  , I am new in BRF+ development. Need your help . While creating BRFPlus artifact in NW 7002 , what will be differences 1) if we create  Application / function / Data object / Ruleset etc  using BRF+ workbench  and use ABAP code for calling /pa

  • Filevault encryption: no security questions, no recovery code; how to revert?

    Running the latest Yosemite (10.10.2) on an iMac (upgraded from Mavericks) ... I decided I wanted to encrypt the boot drive on our iMac, so I clicked to turn on Filevault. Here's what happened: I was NOT offered a recovery key. (As this point, I didn

  • Biztalk 2013 Eventlog.WriteEntry

    On Biztalk 2006R2 (windows server 2003R2), I never had problem writing to eventlog from my Biztalk orchestration. But on BizTalk 2013 (Windows server 2008R2), whenever My Biztalk application tries to write to eventlog, I see the following error: Inne

  • Weird Exchange Calendar problem

    Since the last upgrade I cannot see my calendar entries on the Pre nor can I add new ones to the Pre. What is weird about this is that I still get the alerts 15 min before an appointment even though I can see nothing on the screen. A guy I work with

  • ALERT FILE FOR LOCKS

    HELLO EVERYBODY I want to see the alert file for locks held by users; where could i find it in oralce folder? Regards