package com.javapractice;
public class RemoveWhiteSpace1 {
public static String removeWhiteString(String str){
String whilteSpace=str.replaceAll("\\s","");
System.out.println("Remove White Space of String::" +whilteSpace);
return whilteSpace;
}
public static String removewhiteSpacewithinbuilt(String str){
char[] ch=str.toCharArray();
for(char c:ch){
if(!(c==' ')){
System.out.print(c);
}
}
return str;
}
public static void main(String[] args) {
removeWhiteString(" Bangalore is Beautiful city ");
removewhiteSpacewithinbuilt(" Bangalore is Beautiful city ");
}
}
No comments:
Post a Comment