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 Data Structures Getting There Class Review

Adinel Berehorschi
Adinel Berehorschi
1,771 Points

Compiler bug?

So, when I have to initialize the variable in the constructor, and I use Craig's method, it won't compile. For example when I write it like this : "mCreationDate = creationDate;" I get this error: " symbol: variable author
location: class Treet
./com/teamtreehouse/Treet.java:13: error: cannot find symbol
mDescription = description;
^ " But when i use "this" to refer to the current object, like this: "this.mCreationDate = mCreationDate;" my code works just great.

Why?

Adinel Berehorschi
Adinel Berehorschi
1,771 Points

Hello, @Roland Williams! Thank you for the fast answer. Lately, I got it, it was my mistake. When I was declaring the parameters of the constructor i have declared it wrong, something like the following example:

// bla-bla-bla main class stuff
private String mExample;
public Method (String mExample) {  // instead of public Method (String example)
mExample = example; 
}

1 Answer

Armand J
Armand J
6,733 Points

So the problem is you named the argument for the constructor mExample as well. When you try to set mExample to example below, there is no example variable.

private String mExample;
public method (String **example**){
mExample = example;
}