title: First for loop executes one less cycle
body: <p>This a java program for finding duplicates in two string arrays.</p>
  <pre><code>import java.util.*;
  public class session
  {
      public static void main(String[] args) 
      {
          int flag=0;
          Scanner s = new Scanner(System.in);
          System.out.println(&quot;Enter the number of students in session 1 and session 2&quot;);
          int nk= s.nextInt();
          int ng= s.nextInt();
          String[] ses1 = new String[nk];
          String[] ses2 = new String[ng];
          System.out.println(&quot;Enter the registration nos. for session 1&quot;);
          for(int i = 0; i &lt; nk; i++)
          {
             ses1[i] = s.nextLine();
          }
          System.out.println(&quot;Enter the registration nos. for session 2&quot;);
          for(int i = 0; i &lt; ng; i++)
          {
            ses2[i] = s.nextLine();
          }
          for(int i = 0; i &lt; nk; i++)
          {
              for(int j = 0; j &lt; ng; j++)
              {
                  if(ses1[i].equals(ses2[j]))
                  {
                      flag=1;
                  }
              }
          }
          if(flag==0)
              System.out.println(&quot;No Duplicates&quot;);
          else
              System.out.println(&quot;Error, There are duplicates&quot;);
      }
  }
  </code></pre>
  <p>The first for loop runs for nk-1 cycles not nk cycles. Is there a rule involving multiple for loops?</p>