string - Java - Removing char at -


i don't think have firm understanding of why -1 works in code: place marker allowing program continue run? or guidance appreciated.

public class removingchar {      public static void main(string[]args)     {         string str = "looking out window of small apartment";         string remove = "aeiou";           string x = " ";          for(int i=0; i<str.length(); i++)         {             char c = str.charat(i);              if(remove.indexof(c) == -1)             {                 x+= c;             }         }         system.out.print(x);     } } 

public int indexof(int ch)

if no such character occurs in string, -1 returned.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -