array as a string in java language.

import java.util.*;
public class name{
    public static void main(String[] args) {
        int size;
        Scanner sc=new Scanner(System.in);
        System.out.println("enter the size of array=");
         size =sc.nextInt();
         String name[]=new String [size];
        System.out.println("enter the name=");
        for(int i=0; i<size; i++){
            name[i]=sc.next();
        }
        System.out.println(" names are=");
        for(int i=0; i<name.length; i++ ){
            System.out.println(name[i]);
        }
    }
}

■ Output->

Enter the size of array= 4

Enter the name=>

ved
tarun
ansh
uday

names are=>

ved
tarun
ansh
uday

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.