MrDoyle

Arrays) Initialise Arrays with Starting Values

Jan 25th, 2021
515
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main
  2. {
  3.     public static void main( String[] args )
  4.     {
  5.         String[] arr1 = { "alpha", "bravo", "charlie", "delta", "echo" };
  6.  
  7.         System.out.print("The first array is filled with the following values:\n\t");
  8.         for ( int i=0; i<arr1.length; i++ )
  9.             System.out.print( arr1[i] + " " );
  10.         System.out.println();
  11.  
  12.         Integer[] arr2 = { 1, 2, 3, 4, 5 };
  13.  
  14.         System.out.print("\nThe second array is filled with the following values:\n\t");
  15.         for ( int i=0; i<arr2.length; i++ )
  16.             System.out.print( arr2[i] + " " );
  17.         System.out.println();
  18.     }
  19. }
RAW Paste Data