title: Java: find common characters in two strings
body: <p>I'm asked to write a program that finds the common characters in two strings using the <strong>indexOf(char)</strong> method and a <strong>for loop</strong>. Here's what I have so far - the output comes out blank still.</p>
  
  <pre><code>import java.util.Scanner;
  public class ClassName {
     public static void main (String args []) {
  
     Scanner input = new Scanner (System.in);
  
     String a = "";
     String b = "";
     String c = "";
  
     System.out.print("Enter two words: ")
     a = input.nextLine();
     b = input.nextLine();
  
     for (int i = 0; i &lt; a; i++){
  
        char ch = a.charAt(i);
        if (b.indexOf(ch) != -1){
           c = c+String.valueOf(ch);
           }
        }
  System.out.print("Common letters are: "+c);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><a href="https://i.stack.imgur.com/gNGXz.png" rel="nofollow noreferrer">output here</a></p>
  
  <p>I'm not sure where to go from here.</p>
  
  <p>thanks</p>