Check membership method - checked exception
<p>I have another question regarding checked exceptions. I have attempted to answer the question below.. Below my attempt is the original question and code. Could you let me know if I'm right or how I can change my attempt to make it correct. Kindest regards</p>

<pre><code>public boolean checkMembership(MemberId memberId)
{
    // Firstly the method is tried to see if it works.
    try {
        public boolean checkMembership(MemberId memberId)
    }
    // If it does not work, then the exception is called
    catch (InvalidMemberIdException ex){}
}
</code></pre>

<p>The checkMembership method is part of the Membership class. Its purpose
is to validate the memberId it is passed as its parameter and then try to find it
in a list of members. It returns true if the memberId is found and false if not.</p>

<pre><code>public boolean checkMembership(MemberId memberId)
{
    if (!validate(memberId)) {
        // An exception must be thrown.
        …
    }
    // Further details of the check membership method are omitted.
    …
}
</code></pre>

<p>If the memberId parameter to checkMembership is not valid then an
InvalidMemberIdException must be thrown. Rewrite the part of the
checkMembership method shown above to show how this would be done.
Remember, this is a checked exception. You must include detailed javadoc
comments for the method that conform to good stylistic conventions.</p>
