Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am developing math question and answer app, and i will like to add superscript to some
maths equations like the one below

Question 11 1 (1) +2 (2) +3 (3) +...+10 (10) is divided by 5. What is the remainder?

String questions [] = {"Question 11 1 (1) +2 (2) +3 (3) +...+10 (10) is divided by 5. What is the remainder? ",};

My question is I will like to make the numbers in the brackets superscript, how can i achieve this in a java

Reply soon and thank you
Posted
Comments
Sergey Alexandrovich Kryukov 13-Apr-15 13:53pm    
You could use HTML markup...
Is this application a Java applet? Anything else?
—SA
Member 10627743 13-Apr-15 14:12pm    
Am trying to render the questions in a string array is it possible to use superscript in string array
Sergey Alexandrovich Kryukov 13-Apr-15 14:28pm    
It makes no sense. String is a string, it does not carry any markup. But you can use different Unicode characters for digits.
—SA

1 solution

Please see my comment to the question. Strings themselves, just plain text, don't carry any markup/formatting.

Only in the case when your text in subscript/superscript are just digits, you can use the Unicode character for all decimal digits. I hope I don't need to explain you that Java works with Unicode characters and strings. Watch this:
0⁰₀ 1¹₁ 2²₂3³₃ 4⁴₄ 5⁵₅ 6⁶₆ 7⁷₇ 8⁸₈ 9⁹₉

I did not use any HTML markup in this example. Superscript digits have code points U+2070 to U+2079, and subscripts '- U+2080 to U+2089, there are few more superscripted/subscripted characters. Please see:
http://unicode.org,
http://unicode.org/charts/PDF/U2070.pdf.

Not sure it makes a lot of practical sense, but you got the answer.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900