Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

ankit panwar
436 Pointsrunning perfectly on workspace, but when I tried it on challenge task it givs error for console
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 name= "ankit singh";
console.printf("hello ankit \n" + name"\n");
} }
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 name= "ankit singh";
console.printf("hello ankit \n" + name"\n");
}
}
2 Answers

Carlos Federico Puebla Larregle
21,073 PointsThe interpolation allows you to make a "placeholder" inside of that string so you can put in that place what's inside of a variable, and with the concatenation you can only concatenate two strings. So if you want to concatenate a string with another thing you will have to make an explicit "parse".

Carlos Federico Puebla Larregle
21,073 PointsThe code challenge is asking for you to make interpolation not concatenation, so instead of using the + operator use the % to interpolate a variable:
// I have setup a java.io.Console object for you named console
String firstName = "Federico";
console.printf("%s can code in Java!", firstName);
I hope that helps a little bit

ankit panwar
436 PointsThanks carlos bro , in testing window I only have to type the main code not main function and all that. What is the difference between %s and using + for concatenate