Advertisement
Hiteshw11

Using ArrayList for Strings

Nov 17th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.*;
  2. class Main {
  3.     public static void main(String args[])
  4.     {
  5.         Scanner src=new Scanner(System.in);
  6.         System.out.println("Enter number of strings");
  7.         int n=src.nextInt();
  8.         ArrayList<String> one=new ArrayList<String>();
  9.         for(int i=0;i<n;i++)
  10.         {
  11.             System.out.println("Enter the string");
  12.             one.add(src.next());
  13.         }
  14.         System.out.println(one);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement