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

Hasan Nagaria
Hasan Nagaria
4,855 Points

exception exercise help

I dont understand this question. When I attempt the preview/help comments make little sense.

Anyways, I thought I would do something like

if(firstletter NOT m OR second letter NOT capital){ throw exception. }

Is that it? Im struggling with writing it down in code. I also checked the string directory for a boolean isCaptail but I couldnt find it. What am I doing wrong?

TeacherAssistant.java
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
    return fieldName;
  }

}

1 Answer

Christopher Augg
Christopher Augg
21,223 Points

Hasan,

Yes, you are on the right track with your if statement. Also, the method call you are looking for to test the character's case is not in the String class as you stated. It is in the Character class. Therefore, the two methods you can use are:

fieldName.charAt(int) and Character.isUpperCase(char)

I hope this helps. Please let me know if you need more of a hint if not.

Regards,

Chris