This assignment is designed to give you additional practice with creating arrays.
Put your code in a new empty Java file named "CreatingArrays.java", and make sure to name the class CreatingArrays.
Then, begin with a structure similar to what's listed below.
import java.util.Arrays;
public class CreatingArrays
{
public static void main( String[] args )
{
// part 1
makeAndPrint();
// part 2
int[] a = makeArray();
System.out.println("The returned array contains " + Arrays.toString(a));
// part 3
a = makeRandomOdds(8);
System.out.println("An array with 8 odd numbers " + Arrays.toString(a));
}
public static void makeAndPrint()
{
}
public static int[] makeArray()
{
return null;
}
public static int[] makeRandomOdds( int n )
{
return null;
}
}
Arrays.toString().
The array I just made contains [31, 41, 59, 26, 53, 58, 97, 93, 23, 84]
main().
The returned array contains [13, 14, 95, 62, 35, 85, 79, 39, 32, 48]
main()
will pass in the size of the array to create. In a loop, generate
some random numbers. If the number is odd, add it to the array.
When the array is full, stop looping and return the array.
Display that array in main().
An array with 8 odd numbers [13, 95, 35, 85, 79, 39, 33, 59]