Not exactly: the exact problem I'm trying to figure out is this: Write a static method called makeArray that takes an integer parameter n and that returns an array of integers containing 1 through n with all even numbers at the front of the list in forwards order and all of the odd numbers at the back of the list in backwards order. For example, a call to makeArray(6) should return [2, 4, 6, 5, 3, 1] while the call to makeArray(13) should return [2, 4, 6, 8, 10, 12, 13, 11, 9, 7, 5, 3, 1]. If n is less than or equal to 0, your static method should return an array of size 0.
public static int makeArray(int n)
but once I figure out how to print the array without doing the even odd thing, I can figure the rest out on my own.
i don't see anyplace where it was explicitly said, but... arrays are indexed from 0. what that means is that if you create an array of size 6, your elements are 0-5.
in other words, this:
public static int makeArray(int n) and when I call this method from main I want an array to print out from 1 to n.
isn't correct. you can make the array like that, but the only elements you can print out (because the only elements you have, are 0 through n-1. if you try and display makeArray(n), you'll get an array out of bounds exception. [ June 29, 2004: Message edited by: fred rosenberger ]
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors