I want to use the elements of array comNumber
, in ranNumber()
method
but when I using this in main()
it only shows the address of array.
How can I fix this problem?
public class BaseballGame {
public static void main(String[] args) {
BaseballGame bGame = new BaseballGame();
System.out.println(bGame.ranNumber());
}
public int[] ranNumber() {
Random rand = new Random();
int[] comNumber = new int[3];
for(int i=0; i<comNumber.length; i++) {
comNumber[i] = rand.nextInt(10);
for(int j=0; j<i; j++) {
if (comNumber[i] == comNumber[j]) {
i--;
break;
}
}
}
return comNumber;
}
}