How to Remove white spaces from given String or Char Array
SOURCE : RemoveWhiteSpace.javapublic class RemoveWhiteSpace { public static void main(String[] args) { char[] data = { 'a', 'a', 'b', ' ', ' ', 'c', ' ', 'd', 'e' }; String s = new String(data); String a = s.replaceAll(",", "").replaceAll(" ", ""); System.out.println(a.toString()); }}INPUTchar[] data = { 'a', 'a', 'b', ' ', ' ', 'c', ' ', 'd', 'e' }OUTPUTaabcde

0 comments :
Post a Comment