Okay fine I got it
Printable View
Okay fine I got it
The code tags makes your code much more readable...that being said, think like a computer...step through the code one thing at a time and consider what happens. For example:
what will happen when this line tries to execute? AndCode:for(int index3=numbers.length/2; index3<0; index3++)
when the length of numbers is reduced inside the loop, what will happen to the loop current executing?Code:for(int print=0; print<numbers.length ;print++)
I apologize for no code tags. Well the first loop i believe will increment from the mid-point of the array so it would assign temp2[0]=numbers[4] for example..
As for the second part I thought that might be a problem as well and made a variable to just hold the value before the loop and use that instead. But when i do that i get an error reading
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at datastructures1.Main.main(Main.java:62)"
and it highlights the printing of the numbers...
I can see how that doesnt really work but if I use index3-- which is what I actually had originally i dont get a different outputQuote:
Code:
for(int index3=numbers.length/2; index3<0; index3++)
what will happen when this line tries to execute?
I don't think you see...think about that line. Set index3 equal to some positive value. Check if that value is less than zero...if so, continue, if not exit loop.
The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
Oh okay I see this is what i have:
So now its not returning 0's I'm getting the last number in the text file repeatedly..Code:for(int index2=0; index2<(numbers.length/2); index2++)
{
for(int index3=((numbers.length/2)-1); index3<numbers.length; index3++)
{
temp2[index2]=numbers[index3];//Inputs numbers from original to temporary half sized array
}
}
Im still kinda lost on this problem soo if anybody has any suggestions id like to hear it.
Wasnt aware it was the same website...Since I had to register again...
It's not the same website. Most volunteers feel that their own time is valuable, and mind it if a poster doesn't agree, and cross-posts the same question on multiple fora, thus increasing the chances of someone here or there wasting their time answering a question that has already been answered elsewhere. If you feel you must cross-post, be considerate and notify all threads of this. One of the posters in your cross-posted also gave you a link that goes into more detail about cross-posting and why you should notify all of this.
Also, why did you erase your initial post?