Friday 18 January 2013

remove spaces from string in java

public class RemoveSpace {
public static void main(String[] args) {
String s="hello hai this is karthik";
System.out.println( s.replaceAll("\\s+", " "));
}
}


//input:hello hai this is karthik

//output:hello hai this is karthik

No comments:

Post a Comment