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); } }
if no such character occurs in string, -1 returned.
Comments
Post a Comment