Mirror characters of a string | Java code to find the reverse alphabetical order from a given position ; Function which take the given string and the position from which the reversing shall be done and returns the modified string ; Creating a string having reversed alphabetical order ; The string up to the point specified in the question , the string remains unchanged and from the point up to the length of the string , we reverse the alphabetical order ; Driver function
import java . io . * ; class GeeksforGeeks { static String compute ( String str , int n ) { String reverseAlphabet = " zyxwvutsrqponmlkjihgfedcba " ; int l = str . length ( ) ; String answer = " " ; for ( int i = 0 ; i < n ; i ++ ) answer = answer + str . charAt ( i ) ; for ( int i = n ; i < l ; i ++ ) answer = answer + reverseAlphabet . charAt ( str . charAt ( i ) - ' a ' ) ; return answer ; } public static void main ( String args [ ] ) { String str = " pneumonia " ; int n = 4 ; System . out . print ( compute ( str , n - 1 ) ) ; } }