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

it doesn't want to work, why?

well, first i write the code .....console.printf Console.printf("Hello, my name is Rey"); then i go to the console and write the javac Introductions.java for compile it but when i click enter it makes error.....

Introductions.java:8: error: non-static method printf(String,Ob ject...) cannot be referenced from a static context
Console.printf("Hello, my name is Rey");

This is the error, and i don;t know why because i wrote this like in the video

3 Answers

but however i do it, it still shows the error

Try this:

Introductions.java
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
    console.printf("Hello, my name is Rey");
  }
}

Dude, thanks a lot but it didn't work it still show the error....

If you copy and paste this into your workspace it should work

What about copying/pasting my code, then press Ctrl + S, which will save the workspace.

Thanks Man!!

Please mark this answer best answer, so that others will know that it is solved.