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

How do i set a value to a declared variable in java

How do i set a value to a string already declared variable

Name.java
class Intro{
    String firstName = "Mary";

}

2 Answers

Simon Coates
Simon Coates
28,694 Points

The challenge is looking for is:

String firstName = "Mary";

(this challenge doesn't require that you write a class, or place the code in question inside a method. It's kinda artificial, but a lot of the time, it wants code in isolation and doesn't show the greater context of where the code would be placed if running in any real program. Apologies for the earlier response. I garbled some of the words.)

OMG!!! Thanks so much Simon for the help, i needed it and I removed the class and it worked!!!

Simon Coates
Simon Coates
28,694 Points

no worries. At least your problem was that the code you were writing was too realistic.

Lol, i guess so