Write code to Convert space characters by underscore characters.
test test becomes test_test
use String.replace() method
//package com.book2s; public class Main { public static void main(String[] argv) { String content = "book2s.com"; System.out.println(replaceSpaceUnderscoreChar(content)); }/*from w ww .ja v a2 s . com*/ protected final static char UNDERSCORE_CHAR = '_'; /** * <p>Convert space characters by underscore characters. This method is used in * creating id or handle name from common expression.</p> * @param content original content with space characters * @return string or identifiers with underscore characters */ public static String replaceSpaceUnderscoreChar(String content) { return content.replace(' ', UNDERSCORE_CHAR); } }