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

Excepted "m_first_name"

I thought I did correct but I got bummer: m_first_name What does that mean? And how to solve this out?

TeacherAssistant.java
   // 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

public class TeacherAssistant {
  public static String validatedFieldName(String fieldName) {
    char[] memberName = fieldName.toCharArray();
   if (fieldName.charAt(0) != 'm' ){
      throw new IllegalArgumentException ("must begin with m");
    }
    if (Character.isLowerCase(memberName[0])){
      throw new IllegalArgumentException("name must be uppercased to ensure camel-casing");
    }
    return fieldName;
  }

}

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Oshedhe,

you want to check if the second character inside of the memberName is upper cased or not. So you will need to analize the first index of the memberName like memberName[1], not memberName[0]. And instead using isLowerCase i have used the ! sign to neglect the isUpperCase method like this:

public class TeacherAssistant {
  public static String validatedFieldName(String fieldName) {
    char[] memberName = fieldName.toCharArray();
   if (fieldName.charAt(0) != 'm' ){
      throw new IllegalArgumentException ("must begin with m");
    }
    if (!Character.isUpperCase(memberName[1])){
// if not upper cased on index 1 of the memberName array
      throw new IllegalArgumentException("name must be uppercased to ensure camel-casing");
    }
    return fieldName;
  }
}

Make sense?

Grigorij

AHHHAA!! !Character.isUpperCase(memberName[1]) means if its not uppCase then throw Illigal.. Alright of course! thanks a lot man! :)

Must think logic! ;)

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

:))))))

I love this aaaaaa effects ....

See you in the forum

Grigorij