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

Vivian Cockhern
Vivian Cockhern
81 Points

Defining a string Variable that stores my name. What is wrong with the way I am enter my string Var

What am I doing wrong? I typed variable and when i go to run it the system does not except my code. ( String firstname = " Vivian";)

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

String firstname = "vivian";

11 Answers

Prem Yadav
Prem Yadav
7,346 Points

Q1. String firstName = "Vivian"; Q2. console.printf("<your Name> can code in java"); Q3. console.printf("%s can code in Java",firstName);

these are the answer of all three query which they asked... i hope now it will help you and if not let me know..:)

Prem Yadav
Prem Yadav
7,346 Points

:) most welcome please mark it as best answer by clicking right side upper arrow. thank you.

Prem Yadav
Prem Yadav
7,346 Points

Dear Vivian Cockhern You are doing great but remember whenever you defining variable you must write Access Specifiers of that variable. so your code would be like this

private String firstName = "vivian";

I hope this will help you

Vivian Cockhern
Vivian Cockhern
81 Points

Okay, Why was this not part of the lesson so i could have done it right the first time?

Vivian Cockhern
Vivian Cockhern
81 Points

private String firstName = "vivian"; the system is still not excepting this. what am I doing wrong

Prem Yadav
Prem Yadav
7,346 Points

can you please send your code....?

Vivian Cockhern
Vivian Cockhern
81 Points

How do I send you my code?

Prem Yadav
Prem Yadav
7,346 Points

just copy your code and paste it in the comment only..:)

Vivian Cockhern
Vivian Cockhern
81 Points

private String firstName = "vivian";

Prem Yadav
Prem Yadav
7,346 Points

you also did the same but i don't know why you are not getting error.

Prem Yadav
Prem Yadav
7,346 Points

(why you are getting error)*

Vivian Cockhern
Vivian Cockhern
81 Points

The answer you gave me was correct and the error message I got made no sense. Thanks for all your help, your the best!