Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

I was trying to write the unicode cross symbol in Java. But it is not working, gives the following output:

# javac A.java && java A

ဃ5

Can anyone help me with this?

1 Answer

0 votes
by (26.7k points)

Basically, in able to do that, you need to use UTF-16 surrogate pair form to have the cross symbol:

String cross = "\ud800\udc35";

Also, you can use 32-bit code in the form of an int:

String cross = new String(new int[] { 0x10035 }, 0, 1);

I hope this will help.

Want to know more about Java? Prefer this tutorial on Java Tutorial.

Want to become a Java Expert? Join Java Course now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
4 answers
0 votes
1 answer
asked Sep 27, 2019 in Python by Sammy (47.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...