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 trialoliver sarmiento
121 PointsDefine String variable firstName that stores your name. Unable to compile
public class Name { public static void main(String[] Args) { Console console = System.console(); String firstName = "Oliver"; console.printf("Hello" + firstName); } }
public class Name {
public static void main(String[] Args) {
Console console = System.console();
String firstName = "Oliver";
console.printf("Hello" + firstName);
}
}// I have setup a java.io.Console object for you named console
2 Answers
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey Oliver, we don't need to set up a console object, the comment already let us know that this was set up.
Second, when you are using print f you don't need to use the to concatenate the string with the addition sign.
All that is needed is to declare your variable then pass in the value like below
console.printf("%s can code in Java!", firstName);
Steve Hunter
57,712 PointsHI Oliver,
You've done that correctly, but added all the other stuff that the compiler isn't looking for. It literally just wants the one line:
String firstName = "Oliver";
Steve.
oliver sarmiento
121 Pointsoliver sarmiento
121 PointsI see. Thank you