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

Android

Java Basics?

Ok I am doing the challenge and the question is Create a new variable called name and accept input from the console using the readLine method. and when I put

String name = console.readLine("What is your name?  ");

I get an error which says

JavaTester.java:2: package java.nio.file does not exist
import java.nio.file.Files;
                    ^
JavaTester.java:3: package java.nio.file does not exist
import java.nio.file.Paths;
                    ^
JavaTester.java:73: cannot find symbol
symbol  : variable Paths
location: class JavaTester.CC
        byte[] encoded = Files.readAllBytes(Paths.get(filename));
                                            ^
JavaTester.java:73: cannot find symbol
symbol  : variable Files
location: class JavaTester.CC
        byte[] encoded = Files.readAllBytes(Paths.get(filename));
                         ^
4 errors

Am I doing something wrong? It says the file is imported and even if I do import it at the top it does not work. Thanks

3 Answers

create a new variable name, String name accept input from the console using the readLine method, console.readLine("");

it should look like this, String name = console.readLine(""); where "" are accepting input

Adding the quotes worked!

Thanks!

If I type in the import is says

JavaTester.java:86: error: ';' expected
imported java.io.Console;
             ^
JavaTester.java:86: error: not a statement
imported java.io.Console;
                ^
2 errors

I do not know what happened, but I just clicked the enter button and it worked so maybe it was just a glitch! (I dont know how to delete a question sorry)