sorting by first character
<p>The question at hand is each policy No. is a string of 9 characters of which indicates the type of insurance policy</p>

<ul>
<li>B for building policy</li>
<li>C for Contents Policy</li>
<li>L for Life policy</li>
<li>V for car policy</li>
</ul>

<p>Each of the remaining 8 characters of the policy number is a decimal digit. </p>

<p><strong>I have tried using charAt but somebody told me there was a slightly better way</strong></p>

<pre><code>public String getpolicyNo(String initpolicyNo) {

    /**
     * Access method to find the first character of the policy to then
     * determine what type of policy it is.
     */
    String b = "B";
    String C = "C";
    String L = "L";
    String V = "V";

    char c1 = b.charAt(0);
    char c2 = C.charAt(0);
    char c3 = L.charAt(0);
    char c4 = V.charAt(0);


    if (c1 == 0) {
        System.out.println("Its building" + c1);
        return initpolicyNo;
    } else {
        if (c2 == 0) {
            System.out.println("Its Content");
            return initpolicyNo;
        } else {
            if (c3 == 0) {
                System.out.println("Its life");
                return initpolicyNo;
            } else {
                if (c4 == 0) {
                    System.out.println("Its car");

                    return initpolicyNo;
                }
            }
        }
    }
    throw new IllegalArgumentException();
}
</code></pre>

<p>I'm not looking for you to provide an answer for me, I'm just looking for any possible alternatives and possible suggestions.</p>

<p>Many thanks</p>

<p>Dan</p>
