I am just wondering how do you print a square root(√) character in Java? I am assuming you use its unicode or something?
Asked
Active
Viewed 2.7k times
2
-
1) find the character; 2) copy it into the source code; 3) pray it's present in the font face where it needs to be. – John Dvorak Mar 28 '13 at 00:32
-
There is a Unicode square root symbol, "\u221A". In this day and age most, but not all fonts, contain the glyph. – Devon_C_Miller Mar 28 '13 at 01:40
3 Answers
1
Here's the unicode number for it: http://www.fileformat.info/info/unicode/char/221a/index.htm
And this prints it out to a file for me:
package com.sandbox;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
public class Sandbox {
public static void main(String[] args) throws ParseException, IOException {
FileUtils.write(new File("out.txt"), "\u221A", "UTF8");
}
}
When I open that file, it has the square root symbol in it.

Daniel Kaplan
- 62,768
- 50
- 234
- 356
1
A question related to this was already asked:
Check out the post and see if this works for you. This site might also have some answers for you:
http://java2everyone.blogspot.com/2009/04/square-root-symbol-in-java.html

Community
- 1
- 1

Dion Pezzimenti
- 243
- 2
- 11