Sudeep Kumar Das

Take an array of names as input from the user and print them on the screen.

Java Basic Codes

Explanation

1374    0

import java.util.*;

 public class Arrays {

   public static void main(String args[]) {

      Scanner sc = new Scanner(System.in);

      int size = sc.nextInt();

      String names[] = new String[size];

 

      //input

      for(int i=0; i

          names[i] = sc.next();

      }

     

      //output

       for(int i=0; i

           System.out.println("name " + (i+1) +" is : " + names[i]);

       }

      

   }

}

 



Share:   

More Questions from Java Basic Codes Module 0