Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public static void main(String[] args) {
  2.         // TODO code application logic here
  3.         Scanner in = new Scanner(System.in);
  4.        
  5.         System.out.println("Hello user");
  6.        
  7.         //Input the size of array
  8.         int size;
  9.         System.out.print("Type the array' size: ");
  10.         size = in.nextInt();
  11.        
  12.         //Declaration of the array
  13.         String[] array = new String[size];
  14.         int i;
  15.        
  16.         //input the elements
  17.         for(i=0; i<size;i++){
  18.             System.out.println("Type a Name: ");
  19.             array[i] = in.nextLine();
  20.         }
  21.        
  22.         //print the elements
  23.         for(i=0;i<size;i++){
  24.             System.out.println("The element "+(i+1)+" is: "+array[i]);
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement