0

Input

import java.util.Scanner; import java.util.ArrayList; public class Input { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Insert name monuments do you want visit: "); ArrayList<String> names = new ArrayList<String>(); int index =0; while(sc.hasNext){ names.get(index)=sc.nextLine(); System.out.println(names[index]); index++; } } } IWhere is the error? Thanks.

26th Apr 2019, 4:09 PM
Silvio Petix
Silvio Petix - avatar
1 Answer
+ 3
use add() to append a new element to ArrayList https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
26th Apr 2019, 4:16 PM
Taste
Taste - avatar