Java ArrayList

public class GeneralizationsD {
public static void main(String[] args) {

	for(String sport : sports) 
ArrayList<String> sports= new ArrayList<String>();

The code comes out with an error. error: variable declaration not allowed here
ArrayList sports= new ArrayList();
1 error

The declaration should be at a point before the loop, not inside it.

Thank you very much! :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.