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

Is this a bug!?

Hi, I have checked the forum for this question and found other people had this same problem. It's not letting me go to the next step even though I am near certain it is correct. In the other answers to this question it talks about something called m prefix, but does't specify how to get past the step. Help would be very appreciated.

this is the question: n User.java, add private fields to store firstName and lastName, and initialize them in the provided constructor. Add public getters for firstName and lastName.

public class User { // TODO: add private fields for firstName and lastName private String firstName; private String lastName;

public User(String firstName, String lastName) { // TODO: set and add the private fields this.firstName = firstName; this.lastName = lastName; }

// TODO: add getters for firstName and lastName public String getfirstName() { return firstName; }

public String getLastName() { return lastName; } }

1 Answer

Hi,

since the code you provided isn't formatted I will state the obvious first:

The code you wrote is not commented, is it?

So your code looks like this?:

public class User {
        // TODO: add private fields for firstName and lastName
        private String firstName;
        private String lastName;

        public User(String firstName, String lastName) {
            // TODO: set and add the private fields
            this.firstName = firstName;
            this.lastName = lastName;
        }

        // TODO: add getters for firstName and lastName
        public String getfirstName() { return firstName; }

        public String getLastName() { return lastName; } 
    }

If it looks like this, then the only thing I could think of is the getter method for the first name

Use correct camelCase --> getFirstName()

If this isn't the solution, please provide the error message and/or format your code.

PS: You can use backticks like this to have a nicely formatted code block.

```java

Here goes your code

```