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

Can someone please elaborate on what this exercise is asking for?

what are the requirements that this question is talking about? Is it that the fieldName needs to contain only letters and that it has to be all lower case?

TeacherAssistant.java
public class TeacherAssistant {

  public static String validatedFieldName(String fieldName) {
       if (){
      throw new IllegalArgumentException("Does not meet the requirements");
    }
    // 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
    return fieldName;
  }

}

1 Answer

Miguel Canas
seal-mask
.a{fill-rule:evenodd;}techdegree
Miguel Canas
Python Development Techdegree Student 11,470 Points

Hi brenoannes,

This exercise is asking you to verify that the fieldName argument passes the rules defined in the comment.

You can read the rules as:

  • The first letter of fieldName must be "m"
  • The second letter of fieldName must be uppercase.

If fieldName passes these rules, return the fieldName. Otherwise, throw an IllegalArgumentException.

For example:

  • If I were to call validateFieldName("foobar") I expect to get an IllegalArgumentException.
  • If I were to call validateFieldName("fooBar") I expect to get an IllegalArgumentException.
  • if I were to call validateFieldName("mFoobar") I expect the return value to be "mFoobar".

Hope that helps,

  • Miguel

Geez, my bad, I was overthinking as I had the previous lesson in mind. Some times you forget how simple these exercises are meant to be. Thank you Miguel.