Ad
  • Default User Avatar

    Java has dynamic arrays called ArrayList.
    But your solution doesn't need them, just think about what Chrono79 said.
    It is possible to know its size beforehand.

  • Default User Avatar

    Strings in Java are immutable, but if you reassign them, your command should do what you want.
    str = str.replaceAll(" ","");
    If you want to remove all non-visible characters (e.g. tab, \n), go with:
    str = str.replaceAll("\s+","")