[SOLVED]Adding elements before and after array
Hi all,
I'm new to Java and I'm having this problem with adding elements alternately in front and behind an array.
The methods to add the elements I have already figured out.
I also came up with a method to add the elements alternately to the array, but my instructor told me it could be done with a boolean instead of what I have now.
My method now is to keep up count when the data that needs to be added is read and whenever the count odd it adds data BEHIND and whenever it's even it adds data IN FRONT of the array.
Code:
in.useDelimiter("=");
int count = 0;
while (in.hasNext()) {
String array = in.next();
Scanner arrayScanner = new Scanner (array);
if (count%2==0) {
coordinateArrayInput.addInFrontArray(readArray(arrayScanner));
} else {
coordinateArrayInput.addBehindArray(readArray(arrayScanner));
}
count+=1;
Could anyone please tell me how to fix this problem with the boolean my instructor is talking about?
Thank you.
Yours,
liQuorice