Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Local Development Environments Exploring Your IDE Clean up this mess

I am receiving a compiler error :(

I am receiving a "cannot find symbol" error due to the reformat of code in IntelliJ. If I add import java.util.*, the compiler error disappears but I can't pass the challenge. If I change ArrayList<String> numberWords; to List<String> numberWords;, I still receive the same error.

```public class Messy {

public static void main(String[] args) {

ArrayList<String> numberWords; /* Please comment out this line and this line as well with a hotkey that does multi-line commenting*/

    numberWords = Arrays.asList("six", "seven", "eight", "nine");
    for (String numberWord : numberWords) {
        System.out.println("one");
        System.out.println("two");
        System.out.println("three");
        System.out.println("four");
        System.out.println("five");
        System.out.println("six");


        // Use the sout shortcut to write out numberWord;
    }
    System.out.println(numberWords);
}

}```

Messy.java
public class Messy {

    public static void main(String[] args) {
ArrayList<String> numberWords;
              /*  Please comment out this line and
                this line as well with a hotkey that does multi-line commenting*/

        numberWords = Arrays.asList("six", "seven", "eight", "nine");
        for (String numberWord : numberWords) {
            System.out.println("one");
            System.out.println("two");
            System.out.println("three");
            System.out.println("four");
            System.out.println("five");
            System.out.println("six");


            // Use the sout shortcut to write out numberWord;
        }
        System.out.println(numberWords);
    }
}
results.txt
"C:\Program Files\Java\jdk1.8.0_291\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1\lib\idea_rt.jar=64987:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_291\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_291\jre\lib\rt.jar;C:\Users\ayana\IdeaProjects\Messy1\out\production\Messy1" com.company.Main
one
two
three
four
five
six
one
two
three
four
five
six
one
two
three
four
five
six
one
two
three
four
five
six
[six, seven, eight, nine]

1 Answer

I figured it out. I had to use the Intention Action and change to import.java.Arrays and import.java.List to pass. The code reformatter did not change it from the import.java.utils as I believe it was expected to do.