Unicode does have superscript versions of the digits 0 to 9: http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

This should print 2⁶:

 System.out.println("2⁶");

 System.out.println("2\u2076");
Answer from Thilo on Stack Overflow
🌐
W3Schools
w3schools.com › java › ref_math_pow.asp
Java Math pow() Method
Java Examples Java Videos Java ....println(Math.pow(8, -1)); System.out.println(Math.pow(10, -2)); Try it Yourself » · The pow() method raises a number to the power of another number. public static double pow(double base, double ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › math-pow-method-in-java-with-example
Math pow() Method in Java with Example - GeeksforGeeks
March 28, 2025 - Example 1: This example demonstrates how to use the Math.pow() method in Java to calculate the power of a number (base raised to the exponent). ... // Java program to demonstrate working // of Math.pow() method // importing java.lang package ...
Discussions

How to output a number raised to the power in Java
Daniel Silva is having issues with: Hello, I'm finishing up this application I am writing that displaced the cubic feet of boxes. However it's just printing 355ft. I need it to pri... More on teamtreehouse.com
🌐 teamtreehouse.com
3
February 20, 2017
pow - Does Java have an exponential operator? - Stack Overflow
Is there an exponential operator in Java? For example, if a user is prompted to enter two numbers and they enter 3 and 2, the correct answer would be 9. import java.util.Scanner; public class More on stackoverflow.com
🌐 stackoverflow.com
Is the any way to display an exponent symbol in Java?
What do you mean by "display"? If your display device supports Unicode, then use character U+00B3 SUPERSCRIPT THREE , '³'. In Java code you can refer to this character as \u00b3. More on reddit.com
🌐 r/learnprogramming
6
0
May 10, 2014
How to print powers in Java? - Stack Overflow
Is there a way to print powers in java ? I am not talking about Math.pow(a, b) . In the terminal window, is it possible to print powers such that b is as a superscript ? I tried using the System.out. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Learn Java
javatutoring.com › java-program-to-calculate-exponent
Java Program To Calculate Exponent Value | 4 Ways
1 month ago - In the example, 83 is given where 8 is the base and 3 is the exponent. So, the number 8 is to be multiplied thrice. ... © 2026. Copyrighted Protected. Duplication or Copying Our Site Content Is Strictly Prohibited. However, Reference Links Are Allowed To Our Original Articles - JT. ... Java program to print plus star pattern program – We have written the below print/draw ...
🌐
JanbaskTraining
janbasktraining.com › home › what is java exponent and how to do exponents in java?
What Is Java Exponent And How To Do Exponents In Java?
August 25, 2024 - What is Math POW () in Java and how to use it? Ans:- Math pow() function in Java is used to calculate the power of any base number in Java. you can use it in the following way: ... System. out. println("5^4 is "+ans1);
Find elsewhere
🌐
Medium
rameshfadatare.medium.com › java-program-to-calculate-the-power-of-a-number-4e8f493e1c24
Java Program to Calculate the Power of a Number | by Ramesh Fadatare | Medium
December 13, 2024 - Using Math.pow(): The Math.pow() method is a built-in function in Java that calculates the power of a number. It takes two arguments: the base and the exponent. Using a Loop: A loop is used to multiply the base by itself as many times as indicated ...
🌐
Codingzap
codingzap.com › home › blog – programming & coding articles › what is java exponent? how to do exponents in java?
What is Java Exponent? How to do exponents in Java? - Codingzap
September 25, 2025 - ... At first, we will provide data for Base and Power Values. Now, we will call the Pow() Method, and two arguments (Base and Power) will be passed following the syntax. By default, the Pow() method returns the Double Data Type.
🌐
Techwalla
techwalla.com › tech support › how to
How to Do Exponents in Java | Techwalla
November 30, 2020 - The syntax is "math.pow(base, exponent)" with the number you want raised to the power where it says "base" and the power you want it raised to where it says "power." You can make the result an integer by using (int) before the function, but ...
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › Math › getExponent
Java Math getExponent() - Get Floating Point Exponent | Vultr Docs
December 3, 2024 - Use Math.getExponent() to find the exponent part of the double value. java Copy · double value = 150.45; int exponent = Math.getExponent(value); System.out.println("Exponent of " + value + " is: " + exponent); Explain Code · This code snippet ...
🌐
Programiz
programiz.com › java-programming › examples › power-number
Java Program to Calculate the Power of a Number
Java Math pow() class Main { public static void main(String[] args) { int base = 3, exponent = 4; long result = 1; while (exponent != 0) { result *= base; --exponent; } System.out.println("Answer = " + result); } } Output · Answer = 81 · In this program, base and exponent are assigned values ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › calculating-the-power-of-a-number-in-java-without-using-math-pow-method
Calculating the Power of a Number in Java Without Using Math pow() Method - GeeksforGeeks
January 22, 2026 - Java · class GFG { public static void main(String[] args) { int base = 3, exponent = 3; int result = 1; int i = exponent; while (i > 0) { result *= base; i--; } System.out.println(base + "^" + exponent + " = " + result); } } Explanation: Initialize ...
🌐
W3Schools
w3schools.com › java › ref_math_getexponent.asp
Java Math getExponent() Method
System.out.println(Math.getExp... System.out.println(Math.getExponent(0.5)); System.out.println(Math.getExponent(-0.33)); ... The getExponent() method returns the unbiased exponent of Java's internal representation of a floating point ...
🌐
iO Flood
ioflood.com › blog › math-pow-java
Java's Math.pow() Function | Guide to Exponents in Java
February 29, 2024 - The Math.pow() function is a built-in method in the Math class in Java. It is used to perform the power operation, which is raising one number (the base) to the power of another (the exponent).
Top answer
1 of 1
3

Yes. You can do it like this. This is the unicode version for superscript. There are other codes that let you do letters and other digits. This is just an example. Here is a link for the digits and some special characters. I do not know how stable this link is.

System.out.println("km\u00B2");
System.out.println("2\u00B3");

prints

km²
2³

If the target output device supports it, you can also use html.

System.out.println("km<sup>2</sup>")
System.out.println("2<sup>3</sup>")

Update

I have included some code to facilitate multi-digit exponents.

  • first, create an array of unicode exponents from 0 to 9 inclusive.
String[] uniDigits = new String[10];        
for(int i = 0; i < 10; i++) {
    uniDigits[i] = switch(i) {
        case 2,3->Character.toString(0xB0+i);
        case 1 -> Character.toString(0xB9);        
        case 0,4,5,6,7,8,9->Character.toString(0x2070+i);
        default -> throw new IllegalArgumentException();       
        };
}

Then I created a BiFunction which takes the exponent and the digit array as arguments and returns the exponent.

BiFunction<Integer, String[], String> exponent = (exp, unis)-> {
    int offset = 0;
    StringBuilder sb = new StringBuilder();
    if (exp < 0) {
        offset = 1;
        exp = -exp;
        sb.append(Character.toString(0x207B)); // minus sign
    }
    int digits = exp == 0 ? 1 : (int)Math.log10(exp)+1;
    while(digits-- > 0) {
        sb.insert(offset, unis[exp%10]);
        exp/=10;
    }
    return sb.toString();
};
    
System.out.println("10%s".formatted(exponent.apply(213,uniDigits)));
System.out.println("15%s".formatted(exponent.apply(-38,uniDigits)));

prints

10²¹³
15⁻³⁸

Instead of using the BiFunction directly, you can also return a Function that takes a single argument of exponent and calls the BiFunction with the exponent and the digit array.

Function<Integer, String> expf = exp-> exponent.apply(exp,uniDigits);

It does the same thing, just saves some typing if you have to sprinkle them around in your code.

🌐
Quora
quora.com › How-do-I-find-the-exponential-of-any-number-in-Java
How to find the exponential of any number in Java - Quora
The package provides an in-built method Math.pow(double a, double b) for finding the exponential of any number to a power. Though make sure to remember, that this method returns a double type value...
🌐
Letstacle
letstacle.com › home › java › how to do exponents in java?
How to do Exponents in Java? - Letstacle
April 10, 2023 - The most convenient way to calculate the exponent in Java is by using Math.pow() function.