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);
}

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 ) ; }
replace the last occurrence of from with to
