So I got this school assignment:
Write a method to take two integer arrays and sort
x[]
intoy[]
using foreach loop.
x[]
is size 10 and has all elements initialized with Math.random()
, and y[]
is of size >10 and filled with zeroes. The method should sort the x[]
array into y[]
and return y[]
.
Since I'm only left with foreach I can't figure a way to refer to other elements in the array in order to compare them. Any ideas?
for (E elem : collection) {}
but are you SURE you have to use it? – gd1 Feb 20 '13 at 23:03Math.random()
returns adouble
and you're sortingIntegers
- how do you plan to convertdouble
toint
? – alfasin Feb 20 '13 at 23:06