Noob question about a statement in a Java program
<p>I am beginner to java and was trying out this code puzzle from the book head first java which I solved as follows and got the output correct :D</p>

<pre><code>class DrumKit
    {
        boolean topHat=true;
        boolean snare=true;
        void playSnare()
            {
                System.out.println("bang bang ba-bang");
            }
        void playTopHat()
            {
                System.out.println("ding ding da-ding");
             }


    }

public class DrumKitTestDriver
    {

        public static void main(String[] args)

            {
                DrumKit d =new DrumKit();

                if(d.snare==true)

                    {
                        d.playSnare();
                    }

                                //d.snare=false;

                   d.playTopHat();

            }

    }
</code></pre>

<p>Output is ::</p>

<p>bang bang ba-bang
ding ding da-ding</p>

<p>Now the problem is that in that code puzzle one code snippet is left that I did not include..it's as follows</p>

<p>d.snare=false;</p>

<p>Even though I did not write it , I got the output like the book. I am wondering why is there need for us to set it's value as false even when we know the code is gonna run without it too !??</p>

<p>I am wondering what the coder had in mind ..I mean what could be the possible future use and motive behind doing this ?</p>

<p>I am sorry if it's a dumb question. I just wanna know why or why not to include that particular statement ? It's not like there's a loop or something that we need to come out of. Why is that statement there ?</p>
