Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
ArrayList<String> name = new ArrayList<>();
- this is the same as
your first line does not make sense, because you are not passing a generic type to the constructor. ArrayList<String> name = new ArrayList<String>();
First, if you do not need anything specific ArrayList<T>
, then it is better to use type variables List<T>
.
Second, try running this code:
ArrayList<String> name = new ArrayList(Arrays.asList(1,2,3));
for (String s : name) {
System.out.println(s);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question