// StringMethodsMore.java (c) 2005 Kari Laitinen // http://www.naturalprogramming.com // 2004-10-09 File created. // 2005-04-16 Last modification. class StringMethodsMore { public static void main( String[] not_in_use ) { String first_string = "AAABBBCCCDDD" ; String second_string = "xxxyyyzzz" ; System.out.print( "\n CHARACTER POSITIONS : 01234567890123456" ) ; System.out.print( "\n Original first_string : " + first_string ) ; System.out.print( "\n Original second_string : " + second_string ) ; first_string = second_string.substring( 0, 5 ) + first_string.substring( 5 ) ; System.out.print( "\n Modified first_string : " + first_string ) ; if ( first_string.regionMatches( 0, second_string, 0, 5 ) ) { System.out.print( "\n The first five characters in both strings are the same" ) ; } if ( first_string.contains( "CCCD" ) ) { System.out.print( "\n String \"" + first_string + "\"includes string \"CCCD\" in index position " + first_string.indexOf( "CCCD" ) + ".\n" ) ; } } }