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

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,365 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,365 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