title: How to replace string characters from an array
body: <p>I'm trying to create an encryption scheme that replaces the letters in a <code>String</code> with a corresponding letter. </p>
  
  <p>For example, in the string "apple", the "a" is replaced with "k", and so on. Each letter has a fixed corresponding letter.</p>
  
  <p>I want to get user input and store it into an array.
  Then I want to loop through the array and find each index of the <code>String</code>. Then replace each index with the corresponding letter. </p>
  
  <p>Here's what I cooked up so far but I'm unable to make the code run. I'm mainly getting, <code>error: incompatible types</code>. </p>
  
  <p>I can't determine whether I should be using the <code>charAt</code> method and changing my variable types to char. </p>
  
  <pre><code>import java.util.*;
  
  public class Encrypt {
  
      public static void main(String [] args) {
          Scanner input = new Scanner(System.in);
          System.out.println("Enter the String Name to encrypt:");
          String inputString = input.nextLine();
          String[] str = new String[inputString];
          replaceString();
      }
  
      public static void replaceString() {
  
          for(int i = 0; i &lt; str.length(); i++) {
              if(str.indexOf(i) == "a") {
                  str.indexOf(i) = "k";
              } else if(str.indexOf(i) == "b") {
                  str.indexOf(i) = "n";
              }
              //and so on A-Z...
              System.out.print(str);
          }
  
      }
  }
  </code></pre>