简体   繁体   中英

“Cannot find symbol” Error in Java. Something with my ArrayList is off

import static java.util.Arrays.asList;
class UNIT5 extends ArrayList
{public static void main(String args[])
 {
 String sentence="Extremely";
 ArrayList<String> words= new ArrayList<String>();
 System.out.println(sentence);
 }
}

So this was my code for Java and when I attempt to compile it, the compiler tells me that all of the ArrayList or capital Array A's are symbols that can't be found.

You are using ArrayList without importing it. So import it like:

 import java.util.ArrayList;

Note aside, Your extension ArrayList doesn't makes sense. Also your static import as you are not using it, so you should get rid of those. Also ArrayList deals with Generics which your code doesn't.

您需要导入ArrayList

import java.util.ArrayList

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM