0

Hi:

I have to write a program that uses methods and arrays. I have to create a method that creates an array and populates it with 10 random numbers between 1 and 10 inclusive. Then I have to write another method that sorts the number from lowest to highest and print then in the console. So far so good, except I'm generating a 0 as a value, and I cannot have a 0, only numbers between 1-10 :?

Here's what I got so far

```
public class SortTenDigits {
public static void main(String[] args) {
///Main method to call other methods
int[] numbers = new int[10]; //create array for space for 10 numbers only
populateArray( numbers );
sortPrintArray( numbers );
} // main end
public static int[] populateArray( int[] numbers ) { //populates array with numbers
for ( int i = 1; i < numbers.length; i++) {
numbers[i] = (int)(1 + Math.random() * 10); //create numbers between 1 and 10
}
return numbers;
}//populateArray end
public static void sortPrintArray ( int[] numbers ) { //sort and print the numbers
for ( int el : numbers ) { //copy numbers array to array el
for ( int i = numbers.length - 1; i >= 1; i--) { //toggle between the numbers and place them in order
int Max = numbers[0];
int maxIndex = 0;
//Find the maximun value and assign it to the Max
for ( int j = 1; j <= i; j++) {
if ( Max < numbers[j] ) {
Max = numbers[j];
maxIndex = j;
}
}
//swap values if necessary
if ( maxIndex != i ) {
numbers[maxIndex] = numbers[i];
numbers[i] = Max;
}
}
//Print results
System.out.println( el );
}//for end
} //printArray
}
```

Any hints to my problem would be greatly appreciated :)