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!

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 Objects (Retired) Delivering the MVP Validation

Hey all, I'm stack in this quiz of checking the style of fieldName if the first letter is 'm', the second is UpperCase

I think that I don't understand what the quiz want to check. Because I have written the code in a different styles but it still showing me that it is not correct. I do not have a syntax or logic problems, but my code does not meet the functionality that the quiz ask for.

Would you please show me what is wrong with my code

Thanks in advice

public class TeacherAssistant {

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


1 Answer

Alexander Nikiforov
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,174 Points

Make sure you check community answers for help, by clicking at "Validation" at the top of the page above the title fo your question, where you see

Java -> Java -> Objects -> Delivering the MVP -> Validation

Here is direct link, just in case


Would be nice also to check answers below the video before this code challenge.

This is the nice answer from link above:


I tried to play with your solution... It looks good to me, but I don't know why it fails sometimes. But solution here for example suggest that you put into if condition when fieldName is accepted, and not the condition when fieldName is wrong