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, Variables, and Formatting

what could be the problem

rectify me please

Name.java
String firstName="roshaan";
console.printf("roshaan");

4 Answers

Daniel Szepanski
PLUS
Daniel Szepanski
Courses Plus Student 5,098 Points

Hi, try to declare your console like ->

Console cons = System.console();
String firstName = "roshaan";
cons.printf("Hallo %s", firstName);  // <--don't forget to use your variable

or as Aymen Hachicha said use System.out.printf("Hallo %s", firstName);

Hope i could help you.

Aymen Hachicha
Aymen Hachicha
12,653 Points

It's System.out.printf(); not console.printf :)

Matthias Nörr
Matthias Nörr
8,614 Points
String firstName = "roshaan";
System.out.print(firstName);

The problem is still there. In the first line you create a new variable called firstName and store "roshaan" inside. If you want to print out the String-Variable you have to insert the name of the variable into the print-command.

Aymen Hachicha
Aymen Hachicha
12,653 Points

printf or println not print ..

Matthias Nörr
Matthias Nörr
8,614 Points

System.out.print does also compile. It just does not look pretty.