package com.leetcode;/*** 移除字符串中空格*/
public class RemoveSpaceFromStr {public static String removeWhiteSpaceFromStr(String input){StringBuilder output=new StringBuilder();char[] chars=input.toCharArray();for (char c : chars) {if(!Character.isWhitespace(c)){output.append(c);}}return output.toString();}public static void main(String[] args) {System.out.println("removeWhiteSpaceFromStr(\"Hello world !\") = " + removeWhiteSpaceFromStr("Hello world !"));}
}