Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Delivering the MVP Validation

Validation test failing

No compiler errors are thrown in Preview, but solution fails with error: Bummer! Expected "m_first_name" to fail but it passed.

Where is "m_first_name" coming from in this example?

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("member field " +fieldName+ " doesn't start with m.");

 // 2.  The second letter in the field name must be uppercased to ensure camel-casing
    boolean lowCase = Character.isLowerCase(fieldName.charAt(1));
    if (lowCase) {   
        throw new  IllegalArgumentException("member field " +fieldName+ " second char is not upper case.");
    return fieldName;

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,363 Points

Hi MIchael,

you can use this:

boolean lowCase  = Character.isUpperCase(fieldName.charAt(1);


 if (!Character.isUpperCase(fieldName.charAt(1))) {
            throw new IllegalArgumentException("some massage"); 

for the upper case examination.


Thanks G, using isUpperCase() instead of isLowerCase() seems to deal with illegal characters in a more expected way.

Grigorij Schleifer
Grigorij Schleifer
10,363 Points

Hey M :smiley:

the logic of your code is good, but I think the challenge wants us to use isUpperCase() method.

See you in the forum