Saturday 12 April 2014

fixed how to remove space in string in java

fixed how to remove space in string in java.
resently i have to remve from string here is exmape how to remove Whitespace from given string

/*******************************************************************************/
public class RemovingWhitespace {

    /**
     * @param args
     */
    public static void main(String[] args) {
       
        String st="2013 2014 2015 2016 3017 2018 2019 2120";
       
        String newString =st.replaceAll("\\s+","");
       
        System.out.println(newString);
    }

}

/*******************************************************************************/
/* Result is
 * 20132014201520163017201820192120
 */

No comments:

Post a Comment