question: private static String replaceLast ( String str , char from , char to ) { int index = str . lastIndexOf ( from ) ; if ( index == - 1 ) return str ; return str . substring ( 0 , index ) + to + str . substring ( index + 1 ) ; }
target:  replace the last occurrence of from with to