Answer the question
In order to leave comments, you need to log in
How to end a dynamic array?
I have an array to which I add elements and I need to stop it with an enter. How to do it?
packagecom.company;
import java.util.ArrayList;
import java.util.Scanner;
public class name {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
ArrayList arguments = new ArrayList();
arguments.add(input.next());
while (input.hasNext()) {
arguments.add(input.next());
}
System.out.println(arguments);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question