Write code to remove Spaces from a string with StringTokenizer
//package com.book2s; import java.util.StringTokenizer; public class Main { public static void main(String[] argv) { String s = "book2s.com"; System.out.println(removeSpaces(s)); }/* w w w . j a v a2s . co m*/ public static String removeSpaces(String s) { StringTokenizer st = new StringTokenizer(s, " ", false); String t = ""; while (st.hasMoreElements()) { t += st.nextElement(); } return t; } }