If statement Validation
<p>trying to write a simple Java program that accepts a string and validates against two criteria. </p>

<p>If the word is shorter than 4 letter it asks the user to re enter a word till it is four letters.. </p>

<p>Once that criteria is true it evaluates it against the letters. If the first letter of the four letter word is a D then it prints a silly message "The D was found" if not "No D found"</p>

<p>So far what i have working is validation for the four letters. It checks that it is four letters and if its not it keeps asking till it gets a four letter word.</p>

<p>After that when i enter the four letter word i cant get it to validate on the next if which checks if it is greater than 4 letters and then checks if it starts with a D or not. </p>

<p>import java.util.Scanner;</p>

<p>public class POD1</p>

<p>{</p>

<p>private static Scanner scan = new Scanner(System.in);</p>

<pre><code>private static String word;
public static void main(String [] args)
{
    System.out.println("Please enter a 4 Letter word");
    word = scan.next();

    if(word.length() &lt;4) 
    {    
        System.out.println("Word is to short ");
        System.out.println("Plese re-enter");
        word = scan.next();
    }

    if(word.length() &gt; 4)
    {
        if(word.charAt(1) == 'd')      
        {
            System.out.println("Big d"); 
        } else

        if( word.charAt(1) !='d')
        {
            System.out.println("No big d");
        }
    } 
}
</code></pre>

<p>}</p>

<p>UPDATE </p>

<p>The code now does go past 4 letter words but even if the word starts with a d it prints out no big d even though it starts with a d</p>