Error applying the if/else statement in java
<p>I'm having problems with my code and hope someone can see what I'm missing.  My code is as follows:</p>

<pre><code>import java.io.IOException;

class Boat{

    String boatName = (" ");
    boolean sailUp = false;

}

public class Project2{

    public static void main(String[] args){

        System.out.println("\n");

        Boat[] boatArray;

        boatArray = new Boat[args.length];

        for(int i = 0 ; i &lt; args.length ; ++i){

            boatArray[i] = new Boat();

        }

        for(int j = 0 ; j &lt; args.length ; ++j){

            boatArray[j].boatName = args[j];

        }

        for(int k = 0 ; k &lt; args.length ; ++k){

            String firstLetter = boatArray[k].boatName.substring(0, 1);

            if(firstLetter == ("B")){

                boatArray[k].sailUp = true;

            }else if(firstLetter == ("C")){

                boatArray[k].sailUp = true;

            }else if(firstLetter == ("N")){

                boatArray[k].sailUp = true;

            }else{

                boatArray[k].sailUp = false;

            }
        }

        for(int l = 0 ; l &lt; args.length ; ++l){

            System.out.println("\nThe " + boatArray[l].boatName + " is ready to sail...");

            if(boatArray[l].sailUp == false){

                System.out.println("\n\tbut the sail is down, raise the sail!");

            }else if(boatArray[l].sailUp == true){

                System.out.println("\n\tthe sail is up, ahead full!");

            }           
        }
    }
}
</code></pre>

<p>I want the following output:</p>

<p>C:\Documents and Settings>java Project2 Enterprise Challenger Discovery Nimitz</p>

<p>The Enterprise is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>The Challenger is ready to sail...</p>

<pre><code>    the sail is up, ahead full!
</code></pre>

<p>The Discovery is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>The Nimitz is ready to sail...</p>

<pre><code>    the sail is up, ahead full!
</code></pre>

<p>But I get this:</p>

<p>C:\Documents and Settings>java Project2 Enterprise Challenger Discovery Nimitz</p>

<p>The Enterprise is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>The Challenger is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>The Discovery is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>The Nimitz is ready to sail...</p>

<pre><code>    but the sail is down, raise the sail!
</code></pre>

<p>Why isn't the sail state being reset by the third loop?</p>

<p>Thank you,
Joe</p>
