• + 0 comments

    for(int i = 0; i < n; i++){ a[i]=scan.nextInt(); } This piece of code takes input it doesn't print in order for something to be printed we need to use System.out. Therefore this piece of code only accepts input.

    for (int i = 0; i < a.length; i++) { System.out.println(a[i]); } This piece of code displays each element one by one as the value of i increases. Therefore it is only this loop that prints the values and hence only one loop displays the values.