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

hello anyone out there>? the challenge questions are not worded the way the training was. So i have no clue what itasks

help

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Rob";
console.printf ("Rob");

13 Answers

Ricky Catron
Ricky Catron
13,023 Points

What the challeges wants you to do is print the variable you saved your name in. You are printing "Rob" when you should be printing the variable name you stored "Rob" in.

Goodluck! --Ricky

ok thx i guess. hmmm. well maybe i will figure it out. i hope

Ricky Catron
Ricky Catron
13,023 Points

Haha I can walk you through it.

String box = "Ricky Catron"

now "Ricky Catron" is stored in the box. If I wanted to print "Ricky Catron" I could simply print box. A.K.A

String box = "Ricky Catron";

console.printf(box);
Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

The instructions are specific. It is asking that you write "Rob can code in Java!". Does your code do that?

i never learned what the "can code" is. so idk what that means. makes no sense to me i figure console.printf ("name"); is what it's asking

Craig Dennis
Craig Dennis
Treehouse Teacher

I think you might be overthinking something. It is a sentence.

console.printf("Rob can code in Java!");

// I have setup a java.io.Console object for you named console String firstName ="Rob"; console.printf ("Rob");

Thats what i have. so it has to be String box="name" even though first one was correct? i feel like a child. Python was so much simpler lol.

Craig Dennis
Craig Dennis
Treehouse Teacher

Ignore the variable name, you had that right originally.

you are kidding me it is literal?

ok that worked fine. idk if this course is for me. if it has literal interpretations i dont think i can do it. it just confuses me cause i am expecting to be challenged on bringing up what i learned. now i really can't focus. Things like this: The code you write in each task should be added to the code written in the previous task." (to me im thinking what is considered a task? everytime i hit next?or is that one entire task?)-- it also confuse me. the way it's worded im not understanding it. Looks like i have some rethinking to do. Thanks for the help both of you guys.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Not sure what you mean by literal interpretations, but I recommend you stick with it, just a few more videos. This is definitely building on what was in the video, and all of the code challenges will do so as well. I think you just got off to a confusing start.

Let me know if you get stuck on anything else.

Happy coding!

i meant the whole can do part...to me im not gonna think to write can do. cause i didnt learn that in previous video. So im already thinking of crazy codes. At this rate i will be having questions on nearly every step. This next one says :Now replace your name with the firstName variable using the string formatter.: whats a string formatter? maybe i dont remember in the videos or i really am crazy and entered an alternate universe

Craig Dennis
Craig Dennis
Treehouse Teacher

Definitely was in the video. %s is a string formatter

right. i remember the %s, but if i put it in the first line, there is nothing to show in next line what the first name is. .maybe im just overthinking this. i will try few more videos.

it may seem funny but i actually code games faster than i can learn this by trial and error. i feel like idk what is happening. maybe im thinking of too many things in my head. again thanks for the help

this was part of the lesson: console.printf ("Hello, my name is %s\n", firstName);

in this challenge, it doesnt apply or work.

if i replace my firstName with---> %s it does nothing. String firstName "%s" <---thats how i am reading this

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

I think you are going to have show your code. I do not understand what you mean by

if i replace my firstName with---> %s it does nothing. String firstName "%s" <---thats how i am reading this

// I have setup a java.io.Console object for you named console

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

according to the way the instructions are written this is how i understand it. //instructions: Now replace your name with the firstName variable using the string formatter.//

sorry dont know how to copy the code properly

Craig Dennis
Craig Dennis
Treehouse Teacher

Oh! Replace your name with the formatter in the printf statement. Just like you mentioned in the video where we did:

console.printf ("Hello, my name is %s\n", firstName);

Do that same thing in the printf line. Use the %s formatter and pass it your firstName variable, which should still be set to your first name (Rob).

Sorry that was confusing for you!

see thats where this comes into play and where i said "the formatting of the instructions, the way it is worded doesn't match what we learned". Cause in the video the reason for the \n was to create a new line. %s is the formatter.

:Now replace your name with the firstName variable using the string formatter. <--instructions doesnt say to use what we did in previous assignment.

how i would write it: Now replace your "name" with "firsName". When you write it like that it becomes simpler than trying to understand your higher knowledge of all this. I feel because you are an expert, you need to literally come down to the horrible 10th grade level of communication. only because everything was written in a way you already know what the task is. you have to write it in a way we would know. at least me. I dont know if i am the first to bring this up. im sure you are tearing your hair out. just be patient with me. I will try it again, just nothing about it says using the \n, "firstName");

sorry i am trying to learn but it's not coming to me. I can write code all day in python and some php formatting of games, but this is just confusing. Videos are great. the explanation and challenges are very hard to understand sometimes what they are asking you to do.

Craig Dennis
Craig Dennis
Treehouse Teacher

Yeah you don't need the \n for this exercise.

please how me how this should look : Use the %s formatter and pass it your firstName variable, which should still be set to your first name (Rob)