import java.util.*; public class MyClass { public static void main(String args[]) { MyClass hw = new MyClass(); String str = "Hi am a not robot ."; System.out.println(hw.removeWhiteSpaces(str)); }
String removeWhiteSpaces(String input){ StringBuilder output = new StringBuilder(); char[] charArray = input.toCharArray(); for(char c : charArray) { if (!Character.isWhitespace(c)) output.append(c); } return output.toString(); } }
Output.
Hiamanotrobot.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Output.