Moving arrays around

Hi,
Ive recently been messing around with some array stuff (only recently started Learning java)
And ive written a program that takes members of a array and moves the first to the end and then moves the rest up one space so in my array of 4 members the member in 0 is moved to 3 and then all the other members are moved up one so 3 becomes 2 and so on.
Now i then went back to try and do it the other way round move the member in slot 3 to 0 and then the others move back but this time ive run into some problems.
Heres the original code i wrote to move 0 to 3:
class Band
     public static void main(String[] args)
          String band[ ] = {"John", "Paul", "George", "Ringo"};
          System.out.println("Original Order");
          //Prints out the array to test its working.
          for (int i = 0; i < band.length; i++)
               System.out.println(band);
          //Changes the order of the array so that John is last.
          String s = band[0];
          for (int b = 0; b < band.length -1; b++)
               band[b] = band[b+1];
          band[band.length - 1] = s;
          System.out.println(" ");
          System.out.println("New Order");
          //Prints out the new ordered array to test its working.
          for (int n = 0; n < band.length; n++)
               System.out.println(band[n]);
Ok so that just outputs the following:
Original Order:
John
Paul
George
Ringo
1st New Order:
Paul
George
Ringo
John
Now heres the new version to move ringo to johns position and the others down one:
class Band
     public static void main(String[] args)
          String band[ ] = {"John", "Paul", "George", "Ringo"};
          System.out.println("Original Order");
          //Prints out the array to test its working.
          for (int i = 0; i < band.length; i++)
               System.out.println(band);
          //Changes the order of the array so that Ringo is first.
          String r = band[3];
          for (int h = 3; h < band.length -1; h--)
               band[h] = band[h-1];
          band[band.length -4] = r;
          System.out.println(" ");
          System.out.println("2nd New Order");
          //Prints out the new ordered array to test its working.
          for (int m = 0; m < band.length; m++)
               System.out.println(band[m]);
Now when i run that this is the part where it all goes wrong and the output is then:
Original Order:
John
Paul
George
Ringo
1st New Order:
Ringo
Paul
George
Ringo
As you can see from that it moves ringo to johns space but the rest dont move.
Can anyone give me a hand in figuring this out as ive spent nearly a whole day working on it for what i think is going to be a simple answer.
Cheers in advance LordOfGood

You should concider using the statndard Collections in this case ArrayList
        List band = new ArrayList(Arrays.asList(new String[]{"John", "Paul", "George", "Ringo"}));
        System.out.println("Original Order");
        System.out.println(band);
        //Changes the order of the array so that Ringo is first.
        String ringo = (String) band.remove(3);
        List band2 = new ArrayList(4);
        band2.add(ringo);
        band2.addAll(band);
        System.out.println("\n2nd New Order");
        System.out.println(band2);

Similar Messages

  • Can the row ID number be locked when moving task around in the schedule?

    I have a schedule in which I want to move row ID 9 to row ID 5; but do NOT want the row ID of 9 to change to 5.  I want to keep original row ID's upon moving them around in my schedule.  Is this possible? If yes, how? 
    Thank you

    Are you trying to do this with a BizTalk app?  2000/2002?

  • Problems moving files around in finder

    Does anyone else have the same problem I do when moving files around in finder. It almost always says you do not have sufficient access privileges and each time I have to go to the destination folder info box and change access permissions. It is now getting really annoying. At work I can not copy files off my laptop to the network as again it says I do not have permission though if I log on from a machine using tiger I can move the files easily. Moving files to my Lacie drive causes the same problem. If anyone out there has and easy fix or explanation I would be grateful

    I decided to go the long way and move everything where I wanted it to be.  I moved everything around in Bridge, I then synchronized the folder to reflect how it should.  So far so good!
    Thank you all for your help and interest, I really appreciate everything!
    I do have one more question now, I will also start a new thread to see what else I can get, but again thank you!
    I have syncroniced the folder after making the changes, and due to the problem I was having last time I did it again just to double check.  It said there were over2k photos missing so I clicked sync, let it do its thing.  And just to tripple check I ran it again and it is saying the same thing, missing over 2k photos.  What does this mean?

  • Moving files around in LR5

    I have imported everything from my external hard drive in LR5 so I can access all of my photos and move them around to organize them.
    I started the organization process and moved files around in different folders via LR5 and I am happy with that.
    I then noticed when I looked at the folders that should now be empty on my hard drive (viewing via Finder) the photos that I have moved in LR5 are still where they originally were when I look at the hard drive in Finder.
    I want the organization that I did in LR5 to be exactly the same when I look at the files and folders on said hard drive in Finder.
    I hope this makes sense and I hope someone out there is able to help me.
    Thanks in advance!

    I decided to go the long way and move everything where I wanted it to be.  I moved everything around in Bridge, I then synchronized the folder to reflect how it should.  So far so good!
    Thank you all for your help and interest, I really appreciate everything!
    I do have one more question now, I will also start a new thread to see what else I can get, but again thank you!
    I have syncroniced the folder after making the changes, and due to the problem I was having last time I did it again just to double check.  It said there were over2k photos missing so I clicked sync, let it do its thing.  And just to tripple check I ran it again and it is saying the same thing, missing over 2k photos.  What does this mean?

  • Finder hangs when moving files around in Flash Drive

    Hello Apple Community! I just wanted to ask a question and a solution to my experience on OS X.
    Recently, I started to experience Finder hanging on me when I move around files from in and out my flash drive.
    What's happening in the picture was me trying to move the ebook into the 'cmpsci3' folder, but Finder hangs from the point.
    I moved the Finder window and the icon just stays there.
    There is nothing really wrong with the movement of files; the moving does work. The problem is that the small file operations
    window disappeared and Finder just hangs there.
    I tried two solutions already:
         1. Remove the com.apple.Finder.plist file from ~/Library/Preferences
         2. Repair disk permissions on both OS X drive and USB03FD (my flash drive).
    Unlucky for me, the problem isn't fixed. I tried to tackle the problem myself and sometimes I see two Finder processes running
    in the Force Quit Applications dialog. I followed the instructions from this threadTwo Instances of Finder Running, but that does
    not work either.
    I looked around and saw that making a new user would fix the problem. I would like the community's advice on how to fix this problem
    before I do anything drastic.
    Thanks for reading and helping me out!

    I decided to go the long way and move everything where I wanted it to be.  I moved everything around in Bridge, I then synchronized the folder to reflect how it should.  So far so good!
    Thank you all for your help and interest, I really appreciate everything!
    I do have one more question now, I will also start a new thread to see what else I can get, but again thank you!
    I have syncroniced the folder after making the changes, and due to the problem I was having last time I did it again just to double check.  It said there were over2k photos missing so I clicked sync, let it do its thing.  And just to tripple check I ran it again and it is saying the same thing, missing over 2k photos.  What does this mean?

  • I am working on a program book in Pages...need help moving pages around...

    I am working on a program book in Pages...need help moving pages around...

    I think word procession mode but I used a magazine template to get started and then just kept adding blank pages to finish...I have done these before without any trouble moving the pages around...so very confused.  Thanks for any assistance. 

  • The selecton tool on illustrator is not grouping or moving graphics around the page

    When using the Selecton Tool on illustrator is not grouping or moving graphics around the page as per normal@

    Try Cmd(Ctrl)-Shift-B which is the toggle for Show/Hide Bounding Box. Sounds like your problem.

  • Moving instances around slugish?

    Moving clips around on a timeline is slow or sluggish when I have my timeline expanded to fill a monitor, when my timeline is reduced as in an adobe window preset the movement of clips is as expected, very responsive.
    When I grab a clip on the timeline it turns to a ghosted clip (looks exactly as a normal clip but ghosted but still has clip name etc when moving around).
    Our other suite has exactly the same software and almost identical hardware and when clips are grabbed on this machine with a large timeline the clips actually turn to a grey only ghost (with no clip details etc) and moving around is very fast and responsive.
    Suite 1 with the issue:
    MacPro 4.1 - MAC OSX 10.6.6 - GTX285 card - 16gigs DDR3 ECC ram
    Suite 2 without the issue:
    MacPro 3.1 - MAC OSX 10.6.6 - GTX285 card - 22gigs DDR2 - FB-DIMM ram
    As mentioned both suites have identical software (all latest versions) and have been rebuilt from the ground up together on the same day.
    We have gone through our settings in premiere together and all prefs etc are the same. We have identical timelines when testing.
    Does anyone know of any setting anywhere else that may be causing this issue?
    Cheers

    Just to let you know, we have 2 systems and have finally
    found that it is something to do with monitor resolution and not with mouse.
    The system I demonstrated in my video which worked fine suddenly had the slow instance movement
    so after some testing we found that it only worked "as it should" when the timeline was
    made full screen (with the " ~ " key) . When we reduce its size in the monitor gradually,
    you can actually get to a point where movement becomes sluggish again.
    My systems maximum monitor resolution is 1920 x 1080 and I can't reproduce this functionality / non functionality.
    The other systems monitors resolution can go higher.
    So in summary there seems to be a definate relashionship between monitor resolution and this annoying sluggish movement.
    It would be great if someone else could confirm this with us.
    Cheers

  • Computer made loud horn noise when moving things around desktop

    The computer made a loud horn noise when moving things around desktop, it was so loud it acctually hurt my ears. No, the computer is not set at a high volume.

    Hi ...
    Open System Preferences > Sound then select the Sound Effects tab.
    Deselect:    Play user interface sound effects
    You may need to restart your Mac for the changes to take effect.

  • Pointer moving all around and programs are opening

    I am trying to use my trackpad as I always have, but my mouse keeps moving around (kind of like it has a mind of it's own).  I also find that programs are randomly opening up and it feels like someone else is in control of my computer.  Help please! 

    I recently had the same thing happen.  I updated and the next day the track pad started working erractically. Tried all sorts of things, but cleaning it solved my problem.  
    To fix it, I turned the computer off, used a cleaner for my eyeglasses and made sure I cleaned the trackpad really well.  I used a tip of a needle to clean out the edges of the trackpad, as it was dirtier than I thought.  Maybe something about the update makes the trackpad more sensitive to dirt.  In other threads I read not to use hand lotions before using trackpad and to keep the trackpad as clean as possible.  
    This completely solved the problem.

  • In Finder since 10.8.3 – delay when quickly moving items around

    I think this is new since the Finder of OS X 10.8.3. It's kind of hard to explain, but here goes:
    If one triest to move items around quickly after each other, there's like a second delay before you can do the second ”grab”.
    Like this: click and drag any item (a file or folder) you have on the desktop, then quickly after releasing it click and drag that same file/folder again or another file and try to move it. There will be a delay before the comand responds. If moving several files quickly after each other this can be a bit irritating.
    I don't think this was the case before, in 10.8.2 and earlier?

    From the Finder menu bar, select
    View > Show View Options
    Is the box marked
    Show Preview Column
    checked? If not, check it.

  • Image quality when moving bitmaps around the stage

    Hey all,
    I am moving an image around the stage, and when it moves
    quickly, it becomes distorted and displays what I can only refer to
    as "banding". The image appear to be misaligned for some of the
    frames that it is moving. I have tried a number of the usual fixes,
    increasing the framerate, using a less complex image, etc. Nothing
    seems to work. Any ideas? I feel like I have seen a lot of flash +
    director movies that have fast motion, slick movement, etc and not
    appear as what I end up with. Is this something that relates to a
    screen refresh rate? Thanks for any ideas...
    - B

    Sounds like good old vertical sync / tearing. This is really
    not a fixable
    issue. You can try slowing down the movement a little...
    Someone, a while
    ago, worked on creating an xtra that would honor the vertical
    blanking
    interval, but it never really worked properly I don't
    believe. You can read
    all kinds of prior posts about this by searching google
    groups within
    macromedia.director.* for 'vertical sync'
    Dave -
    Head Developer
    www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • How to stop Call Center Agents from Moving Headsets around

    We are call center with about 200 agents at a time in the building. We go thru headsets like they are candy. But we just got told to no longer use cheap headsets. So we are slowly cycling in the new headsets. So any Ideas on how to keep headsets from moving stations. Our agents destroy headsets anyway, so I don't know how well these new ones are gonna last. They also move keyboards, mice as well. They have very little respect for the equipment and think breaking them is going to give them a new one faster. Let me know what you guys think.
    This topic first appeared in the Spiceworks Community

    I think you are seeing what is called the Ken Burns Effect. You can change this setting using the Rotate, Crop, Ken Burns Tool on the middle toolbar. You can select Fit, Crop, or Ken Burns. Fit will make your photo fit by letterboxing. Crop will make your photo fit by cropping the top and bottom off. Ken Burns allows you to Pan around. You can set the starting and ending rectangles for the pan.
    Also, if you go to File/Project Properties you can set the default action for "Initial Photo Placement" to Fint, Crop, or Ken Burns.

  • Moving objects around the page

    I want to design a 'spider-gram' using objects in Pages but I find I can't drag the circle and position it in the centre of the page. What am I doing wrong?

    Just insert the arrows as you did with the circle, making sure the text layer is not selected by clicking outside of the layout area first. You can add as many arrows as you'd like or just add one & duplicate it so that it is the same color, length, etc. Assuming these arrows will be set around the outside of the circle, you will want to rotate them using the metrics inspector. You can get precise degrees of rotation by typing a number in the box at the bottom of that inspector. Then move them to touch the circle. Once you get them all placed as you'd like you want to selected all of them & group them. If these are the only graphic elements in the document you can Select All from the Edit menu. Otherwise, click outside the layout area & drag the cursor until you see handles on all of the objects. Now, got to Arrange > Group & they will become one object, easier for any further moving around.
    Peggy

  • Needing help with moving pictures around

    I am in need of help in moving pictures and images around
    dreamweaver document window. My older brother gave me his computer
    witch has dreamweaver MX (he is in Irag) so i can start building
    building my own websites. I went to borders and bought a book on
    dreamweaver MX. Here is where I am having a problem with: when ever
    I bring a picture into the document window I can not move the
    picture around the document window. The book say "place the
    insertion point where you want the image to appear" but there is no
    insertion point. There is just a straight line as if I am about to
    type something. It's almost like I am in microsoft word. If I take
    the mouse over the picture , and then left click and try to drag
    the picture to the location I want it in, it doesn't move. Can
    somebody PLEASE help me out with this problem. Thanks Jical

    Nadia gave you a good place to start… Here is what you
    have to understand. Web pages are based on specific code that tells
    the viewer’s browser how to display the page. There has to be
    something that says, “Put this picture in the lower right
    hand corner, and center this image in the middle of the
    screen”
    Then there are further instructions that say “Put this
    text here and that link there”. So Dreamweaver (and most
    other web developing programs) do not work like Illustrator or
    PowerPoint where you can simply grab a picture and slide it around
    the page.
    In its simplest form you might drag an image onto the
    Dreamweaver design view page and click on the center button in the
    properties dialog.
    Then type in text and center it, left justify, right justify,
    etc. Add another picture and so on and you could possibly create a
    passable web page. Now click on the Code view button and see what
    code Dreamweaver generated in order to do all of this.
    That is what you will really need to understand before you
    can really get proficient at web design.
    At the next level, you can start to add in tables. These
    actually are similar to tables in Word. You can put text in one
    cell, images in another, colored backgrounds, thick and thin
    borders with contrasting colors, and you can start to see how to
    “contain” your images as Nadia suggests.
    Now look at the code again and see how these cells are
    defined around your content.
    Once you understand how this works, you will get much more
    comfortable with Dreamweaver. You will just have to get used to the
    idea that it doesn’t work like all of the publishing software
    that is only dependant upon its own format for layout. HTML is
    dependant upon the many browsers, computers, operating systems,
    user preferences, and a million other unknown factors.
    That’s why this forum has more than 91,000 posts…

Maybe you are looking for

  • Work flow problem with portal

    Hi,    I am facing a workflow problem user is approving  employee transfer via portal but the approval is not moving to next level. I am having the ECR no (Notifiction no), can anybody explain me how to get the Workflow item number using the notifica

  • Solaris 10 hands-off installation from a bootable DVD

    Hello, I have a problem with installing the Solaris 10 using a bootable DVD with a flar archive. I want this installation to be totally hands-off, but unfortunately after I run this boot command at the ok prompt: ok boot cdrom - install ... the syste

  • How do I rotate movies in iphoto 11?

    how do I rotate a movie clip in iphoto 11?

  • IBA -ibooks file crashes my iBooks App

    I have an Ipad 2 running IOS 7.0.2 I just created an .ibook using Ibooks Author, the file is 20.5 mb if I try to open in ibooks on my IPad2 the app crashes. I had the same thing happen before I exported to .ibooks as I tried to preview entire book an

  • Help with HTML View

    Hi, I need help building VC Logic to display 1 of 4 reports (HTTP Links) in an HTML View.  Depending on the value of a incoming data field I want to feed the HTML View a different web page link.  It looks like you can't nest the logic of an if statem