Jump to content
  • Advertisement
Sign in to follow this  
gbizzle

[Java]putting element from array 1 to different index in array 2

This topic is 5002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i summed up best i could in the title. Here's my dilemma: (in Java) i want to loop through PART of one array (say in an array of length 8: start from 4th index and go to 8th) and insert those elements into another array starting from index 0. This method below doesn't work, for obvious reasons: for (int i = 0; i < array1.length-index; i++) { for (int j = index; j < array1.length; j++) { array2 = array1[j]; } } //end i thought i would have 'i' loop through the second array and 'j' loop through the first. But, of course, the inner 'for' loop gets fully executed before moving on to the next index... so how do i make it so one step through the second array(array2) corresponds to one step through the first array? or perhaps i am asking the wrong question? thanks in advance y'all

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

for (int i=0; i<4; i++) array2 = array1[4+i];

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!