add value with n variable with arraylist in java

Solutions on MaxInterview for add value with n variable with arraylist in java by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "add value with n variable with arraylist in java"
Fynn
06 May 2020
1Scanner in = new Scanner(System.in);
2int n = 5;
3ArrayList<String> addName = new ArrayList<>();
4for(int i = 0; i < n; i++){
5  addName.add(in.nextLine());
6}