Explore Courses Blog Tutorials Interview Questions
0 votes
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 && java A


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)

Browse Categories