/**
* @author lautturi.com
* Java example: removing whitespace from strings in java
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
String str = " hello java \n ";
String newString = str.replaceAll("\\s+","");
System.out.println(newString);
}
}
output:
hellojava