title: Find first non repeating character without using hashmap
body: <p>I wanted to find first non repeating character in a string. I wrote the following function in which I am stuck at one point. Google tells me the hashmap method for this but I'll be grateful if someone could help me with my code.</p>
  
  <pre><code>public static Character firstNonRepeatedChar(String line) {
  
          Character c = null;
          int strLength = line.length();
  
          for (int i =0; i&lt;strLength-1; i++){
  
              int flag = 0;
              for(int j = i+1; j&lt;strLength-i; j++){
  
                  if(line.charAt(i) == line.charAt(j)){
                      flag++;
                      break;
                  }
                  else
                      continue;
              }
  
              if (flag==0){
                  c = line.charAt(i);
                  break;
              }
  
  
          }
          return c;
      }
  }
  </code></pre>
  
  <p>Problem : How can I put a check that the repeating character that is already checked once is not checked again.
  Ex: If my string is "hhello" then the code first compares the h at index 0 with all the other characters. Since its repeating the next iteration of outer for loop starts in which i now points to index 1 of the string i.e the repeating h and compares it with the rest of elements. Since it does not get a repeating instance it returns 'h' as non repeating character which is wrong.</p>
  
  <p>How can I fix this? Is there any way?
  Pls help</p>
  
  <p>EDIT: Repeating character need not be the immediate next character. 
  Ex: In string "helloWorld" characters 'l' and 'o' are repeating.
      In string "hehelo" characters 'h' and 'e' are repeating and first non     repeating character will be 'l'</p>