How to use subscript in java string?

ぃ、小莉子 提交于 2019-12-13 05:00:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!