title: Find Positions of a Character in a String
body: <p>How can I find a character in a <code>String</code> and print the position of character all over the string? For example, I want to find positions of <code>'o'</code> in this string : <code>"you are awesome honey"</code> and get the answer = <code>1 12 17</code>.</p>
  
  <p>I wrote this, but it doesn't work : </p>
  
  <pre><code>public class Pos {
      public static void main(String args[]){
          String string = ("You are awesome honey");
          for (int i = 0 ; i&lt;string.length() ; i++)
          if (string.charAt(i) == 'o')
          System.out.println(string.indexOf(i));
      }
  }
  </code></pre>