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

TeacherAssistant challenge has no error code, and does not pass.

public class TeacherAssistant {

  public static String validatedFieldName(String fieldName) {
    // These things should be verified:
    // 1.  Member fields must start with an 'm'
    if (fieldName.charAt(0) != 'm') {
     throw  new IllegalArgumentException(fieldName + "does not start with an m");
    }
    // 2.  The second letter in the field name must be uppercased to ensure camel-casing
    char secondLetter = fieldName.charAt(1);
    if (! secondLetter.isUpperCase()) {
     throw new IllegalArgumentException(fieldName + "is not camel case"); 
    }
    // NOTE:  To check if something is not equal use the != symbol. eg: 3 != 4
    return fieldName;
  }

}

It should work, but it doesn't. I tried to use Java-repl, but I get an error that says there is no main method. So, I try to add one under the class declaration, but it still has errors.

If one were to run this challenge without adding to the original code, they would get a blank error code screen with a header which says, "Expected "firstName" to fail but it passed". This might be a helpful clue, but "firstName" is not in the code originally, just "fieldname" is. So, my question is, should I substitute the fieldname parameter for another inside the code of the class?

After the `` starting your code, can you add "java" so that the code is clearer to read?

Ah ha! Now I know. Thanks.

1 Answer

Whoo Hoo! My TeacherAssistant code finally passed. It is the same code as shown above. I don't know how it passed this time. I just copied and pasted the code that I had commented out in a workspace. Yes, it should work, and did.

That's great, I'm glad you solved it. Sorry I couldn't do it.