rght=str.substring(i+1,n-1);
有问题当i = n-1的时候出错;
下面是:substring方法的说明;
//
public String substring(int start,int end)
//
Returns a new String that contains a subsequence of characters currently contained in this StringBuffer. The substring begins at the specified start and extends to the character at index end - 1. An exception is thrown if 
//Parameters:
start - The beginning index, inclusive.
end - The ending index, exclusive. 
//Returns:
The new string. 
//Throws: 
StringIndexOutOfBoundsException - if start or end are negative or greater than length(), or start is greater than end.