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 Java Basics Getting Started with Java Strings and Variables

I deleted intoductions.java and the class file off the sidebar and cant seem to get the pre written code back?

I deleted intoductions.java and the class file off the sidebar and cant seem to get the pre written code back? when i re opened workspace java basics-intro poped up again in the side bar but no pre written code had popped up in the main centre window

5 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Here's the code I have in that file:

import java.io.Console;

public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
        String firstName = console.readLine("What is your name?  ");
        console.printf("Hello, my name is %s\n", firstName);
        console.printf("%s is learning how to write Java\n", firstName);
    }
}

Just right click on the sidebar and create a new file with the name Introductions.java and paste the above code in there. Then compile and run it.

It does not allow me to paste?

You could also try deleting your workspace, then logging back on to workspaces via the exercise. That should give you a new one with all the code you need.

I deleted workspaces and then tried to re open it and a message came up saying treehouse says un authorised ...basically computer says no

Thanks a million will give it a try now!

For some Reason it wont allow me to paste?

undo, undo, undo, undo. :-)