title: Assigning variables inside the loop
body: <p>Below code is resulting in "<strong>Avoid declaring or assigning variables in a loop that are not dependent on the loop condition</strong>". (According to the coding best practices) </p>
  
  <pre><code> private void testingLoop() {
      String var[]= {"java", "code", "review"};
      String arr[] = new String[1];
      for(String i : var)
      {
      arr[0] = i.concat("Script");
      }  
      System.out.println("The result is: " +arr[0]);
  }
  </code></pre>
  
  <p>Why is it considered as a bad practice when we assign variables inside a loop ? any solution to overcome this problem ?</p>
  
  <p>Note: My intention was only to show the for loop, so don't consider much about the purpose of the code.</p>