Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: Java
Posted by: Thomas Smith
Added: Feb 13, 2018 3:09 AM
Modified: May 7, 2018 11:37 PM
Views: 39
Prints an array of size n to the console with each element seperated by a space.
Also prints a new line at the end of the array.
  1. public static void printArray(int[] a)
  2. {
  3.         int n = a.length;
  4.         for (int i = 0; i < n; i++)
  5.         {
  6.                 System.out.printf("%d ", a[i]);
  7.         }
  8.         System.out.print("\n");
  9. }
  10.