问题
How can I write subscript characters in a Java string?
For example, I have to write "CO2"
. How can I move 2
to the bottom of CO
?
回答1:
The String
class doesn't provide such operations. But you could use the Unicode Character 'SUBSCRIPT TWO' (U+2082):
final String string = "CO\u2082"; // CO₂
Also, you could create a String
as an HTML snippet. For instance,
final String html = "CO<sub>2</sub>";
来源:https://stackoverflow.com/questions/31414960/how-to-use-subscript-in-java-string