title: Comparing elements of two arrays in a for loop (java)?
body: <p>It seems to be a very common question relating with arrays and comparing in java, however I couldn't find the right answer in all of these for my case.</p>
  
  <p>In this application I am trying to make a program which 'encrypts' text given by the user. For example: user gives characters 'a b c' and the program returns it as '@ # $'. But as you may notice I am having some issues in the code 
  "pozita[i] = j;". 
  Why won't this code work? It doesn't give me an error? Or is there anyway of doing it as "new pozita[i]" or anything like that?</p>
  
  <p>Well, I'd be glad if someone could help me through. I am stuck for a while. Thanks in advance! :)</p>
  
  <pre><code>import java.util.*;
  import javax.swing.*;
  import java.awt.*;
  
  public class TestPerProgram extends JFrame
  {
      char[] alfabeti = {'a','b','c','r','n','t'};
      char[] kodimi = {'@','#','%','*','^','$'};
      int[] pozita;
      //Scanner merr = new Scanner(System.in);
  
      String fn = JOptionPane.showInputDialog("Jepe tekstin:");
      char[] input = fn.toCharArray();
  
      void numro()
      {
          for (int i=0; i&lt;=input.length; i++)
          {
              for(int j=0; j&lt;=input.length; j++)
              {
                  if(alfabeti[j] == input[i])
                  {
                      pozita[i] = j;
                      System.out.println(pozita[i]);
                  }
              }
          }
  
          /*
          for (int k=0; k&lt;=input.length; k++)
          {
              System.out.println(pozita[k]);
          }
          */
  
      }
  
      public static void main(String[] args)
      {
          TestPerProgram pjesa = new TestPerProgram();
  
          pjesa.numro();
  
      }
  
  }
  </code></pre>