L
L
le1872017-07-01 17:55:54
Java
le187, 2017-07-01 17:55:54

Guys just starting to delve into programming, what am I doing wrong in this code?

I need to fill an array of 15 elements with random numbers, what am I doing wrong here? Why is the array filled in order from 0 to 15?
packagecom.company;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] mas =new int[15];
Random rand = new Random();
for (int i = 0; i < mas.length; i++) {
mas[i] = rand.nextInt();
System.out.println(i);
}
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anvar Shakhmaev, 2017-07-01
@le187

replace
with
System.out.println(mas[i]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question