Jump to content

Check out our Community Blogs

Fischerspooner's Content

There have been 27 items by Fischerspooner (Search limited from 13-April 20)

Sort by                Order  

#322547 Moving elements in an array

Posted by Fischerspooner on 06 December 2006 - 11:48 AM in General Programming


I'm currently studying Java on my own and I wanted to try to "rotate" elements in an array.
So the start would be:
But if I enter "rotate 1" it should give me

But I keep running into ArrayIndexOutOfBounds errors if I check my pseudocode in Java.

I don't want some code, just a hint or two would be very much appreciated:)

This is what I have already:
for(t=DIM-1 ; t > rot ; t--)
     if(t < DIM)
        k = table[t];
        table[t-1] = table[t];
        table[t+1]= k;
        k = table[t];
        table[t-1] = table[t-DIM];
        table[t+1] = k;

#322544 New guy in town

Posted by Fischerspooner on 06 December 2006 - 11:36 AM in Introductions


Searching the internet about moving elements in an array I bumped on your forum :)
I'm a 29 year old guy getting more and more interested in programming. Just learning Java with BlueJ.
Other hobbies are: getting pierced, tats, music

If you got any questions...fire away:)


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download