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 is rong with this??? please, I'm blocked to thys step I don't understand

// I have setup a java.io.Console object for you named console String firstName="Cata"; console.printf("%s\n is learning Java",firstName); javac Introductions.java java Introductions

Name.java
// I have setup a java.io.Console object for you named console
 String firstName="Cata";
 console.printf("%s\n is learning Java",firstName);
   javac Introductions.java
   javaIntroductions

after i put the semycolon look what is the error

JavaTester.java:75: error: cannot find symbol javac Introductions;java ^ symbol: class javac location: class JavaTester JavaTester.java:75: error: cannot find symbol javac Introductions;java ^ symbol: class java location: class JavaTester JavaTester.java:76: error: cannot find symbol java;Introductions ^ symbol: class Introductions location: class JavaTester

Note: JavaTester.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 3 errors

5 Answers

Ryan Ruscett
Ryan Ruscett
23,309 Points

Call printf on the console object to print something.

String firstName = "Ryan";
console.printf("%s can code in Java!", firstName);

printf is a method on the console object. So we use . notation to call it. Than, in the printf method. It takes parameters. These parameters consist of:

  1. a string
  2. The substitutions

Substitutions most cases are %s (string) or %d (integer). Since our name is a string. We use the %s. Than, the second parameter consist of the variables to substitute %s or %d for. In this instance it's just one. firstName. So we call printf from the console obj and pass it a string with a substitution of type string identified by %s and the second parameter is the variable to put into %s, which is our name.

Does that make sense?

Ryan Ruscett
Ryan Ruscett
23,309 Points

Hey,

First thing is first. You are using the wrong string inside your printf. It's not "%s\n is learning Java" It's "%s can code in Java!". Secondly, you don't need a "\n". That's a new line character. You don't want it to print a single sentence on two lines.

Also

javac Introductions;java

You only use ; when compiling more than 1 file at a time.

test.java ; test1.java ; test2.java

Not

test;java.

String firstName = "Ryan";
console.printf("%s can code in Java!", firstName);

Does that answer your question? If not let me know and I can try another way.

first thank to helping me,it's about 4 hours from when i try to pass away but i can not do it. Yeah i know was wrong that \n it's for more phrases. i've changed but nothig go ok :( i'm lossing me at javac.introd........ from there i recive the error

Ryan Ruscett
Ryan Ruscett
23,309 Points

Are you trying to pass the challenge or build it on your own development environment?

I'm trying to pass the challenge, I'm new to this world.... so how I can call the printf method on the console object and make it write out "<my name> can code in Java!" ??

sorry boys for my bad english =))) but even if my english is bad i recive support and that's important!!!

Tommy Choe
Tommy Choe
38,156 Points

Other than your spelling? =D