0

recently registered on Code Wars and im doing the first exercise where you have to sort words by numbers which are in the words of the sentence.

public class Application {

public static void main(String[] args) {
    String word = "is2 Thi1s T4est 3a";
    System.out.println(order(word));

}

public static String order(String words) {
    String end = "";

    String[] words2 = words.split(" ");

    ArrayList<String> wordss = new ArrayList<String>(Arrays.asList(words2));

    for (int i = 1; i <= wordss.size(); i++) {
        String number = Integer.toString(i);
        for (String words1 : wordss) {
            if (words1.contains(number)) {
                end += words1 + " ";
            }
        }

    }
    return end;
}

}

I did the exercise on NetBeans and it works perfectly fine but when i paste this code into the CodeWars compiler it gives me this error:

./src/main/java/Order.java:10: error: cannot find symbol
   List<String> wordss = new ArrayList<String>(Arrays.asList(words2));
   ^
 symbol:   class List
 location: class Order
./src/main/java/Order.java:10: error: cannot find symbol
   List<String> wordss = new ArrayList<String>(Arrays.asList(words2));
                             ^
 symbol:   class ArrayList
 location: class Order
./src/main/java/Order.java:10: error: cannot find symbol
   List<String> wordss = new ArrayList<String>(Arrays.asList(words2));
                                               ^
 symbol:   variable Arrays
 location: class Order
3 errors

what could be the reason?

serde
  • 59
  • 5
  • Please see [What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?](https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-or-cannot-resolve-symbol-error-mean?rq=1) -- "For identifiers that should be class names: Perhaps you forgot to import the class." – ggorlen Dec 21 '21 at 00:03

1 Answers1

2

You have to import the arraylist >.<

serde
  • 59
  • 5