How do I enter multiple Unicode strings (including the right-to-left order) into a Java source file?


I am testing a piece of Java code and need to create an array of strings. These strings are words in different languages, including those like Arabic with the right-to-left reading order (don't know if that matters...)

So I need to do something like this:

ArrayList<String> words = ...

What's the best way to put these into my Java code? Is there a way to do it other than using "\u" escape for every character in a string? Thanks

In order for it to work you must do these 2 things:

  • Save the source file in Unicode format (UTF-8). How to do this is IDE/Text Editor dependent.

  • Compile the file by specifying the UTF-8 charset. Like this:

javac -encoding utf-8