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 trialHarishkumar Lohar
33 Pointscant understand where the problem is hidden
cant understand the Error please explain
// I have setup a java.io.Console object for you named console
{
Console console = System.console ();
string firstname = "Harry";
Console.print ("%s lernt von anfang an\n", firstname);
Console.print ("%s lernt wie soll JAVA screiben\n", firstname);
}
1 Answer
Richard Lambert
Courses Plus Student 7,180 PointsHello mate,
- For this exercise, an instance of the
Console
class has been created for you and is referenced by the variableconsole
; no need to declare it yourself. - The Console class has the method printf(String fmt, Object... args), used for writing a formatted string to the console's output stream. Looking at the documentation, you will see that the
Console
class has noprint()
method. -
printf(String fmt, Object... args)
is non-static and needs to be called on the object instance,console
, and notConsole
. - No need for the opening and closing braces.
// I have setup a java.io.Console object for you named console
{ // (4)
Console console = System.console (); // (1)
string firstname = "Harry";
Console.print ("%s lernt von anfang an\n", firstname); // (2)(3)
Console.print ("%s lernt wie soll JAVA screiben\n", firstname); // (2)(3)
} // (4)
Hope this helps
Harishkumar Lohar
33 PointsHarishkumar Lohar
33 Pointsthanks Richard