0
public class ReverseStringUnicodeRightToLeftOverrideCharacter {

    public static String reverse(String str)
        {
            
              return '\u202E' + str;
        }
        public static String reverse(String str)
        {
            //return "\u202D" + str;
              return '\u202E' + str;
        }
public static void main (String[] args)
        {
            
"\u202E" + str  is not working in Java

String str = "Techie Delight";
str = reverse(str);

System.out.println("Reverse of the given string is : " + str); 
            
                  
    }
}

For this I'm getting below output:

Reverse of the given string is : ?Techie Delight
deadshot
  • 8,881
  • 4
  • 20
  • 39

1 Answers1

0

You have to concatenate it like this:

public static String reverse(String str)
    {
        return "\u202E"+str+"\u202D";
    }

with "\u202E" as a String not a character at the start and "\u202D" at the end of your string to be reversed.

  • The solution which you mentioned is giving me below output: Reverse of the given string is : ?Techie Delight? – Manali Malkani Jul 26 '20 at 13:33
  • public class ReverseString { public static String reverse(String str) { //return "\u202D" + str; //return '\u202E' + str; return "\u202E"+str+"\u202D"; } public static void main (String[] args) { String str = "Techie Delight"; //byte[] bytes = str.getBytes(StandardCharsets.UTF_8); //String utf8EncodedString = new String(bytes, StandardCharsets.UTF_8); //utf8EncodedString = reverse(utf8EncodedString); str = reverse(str); System.out.println("Reverse of the given string is : " + str); }} – Manali Malkani Jul 26 '20 at 13:36