I want to initialize a String in Java with japanese characters as below.
String str = "最終条件";
But when I type in my Eclipse Java editor, it is displayed like this
String str = "|||||||";
What should be the reason and how can i solve it?
I want to initialize a String in Java with japanese characters as below.
String str = "最終条件";
But when I type in my Eclipse Java editor, it is displayed like this
String str = "|||||||";
What should be the reason and how can i solve it?
Have you tried changing the text file encoding in your project properties?
Right-click on your project, click "Properties" and change "Resource" -> "Text file encoding" to "UTF-8", "Shift_JIS" or any other suitable encoding.
Try changing the font used by the text editor to one that supports Japanese characters. Menu: Window -> Preferences -> General -> Appearance -> Colors and Fonts -> Basic -> Text Font -> Edit
Here is a SO thread about Unicode fonts: https://stackoverflow.com/questions/586503/complete-monospaced-unicode-font
Good luck!
You can also rely on the \u sequences for your Japanese character. For instance, you can use a tool like http://www.snible.org/java2/uni2java.html which converts any char sequence pasted in to the text area into a Java String.