Is there a character within the Math API that allows for representing the character π
?
"\u03C0"
http://www.fileformat.info/info/unicode/char/3c0/index.htm
If you want to write this to a file you can achieve it through Unicodes, below is an example of how,
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception{
BufferedWriter out =
new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("out.txt"),"UTF8"));
out.write("alpha = \u03B1, beta = \u03B2 ,pi = \u03C0");
out.flush();
out.close();
}
}
out put : alpha = α, beta = β ,pi = π
You don't even need to use the Math API. In Java source code, this:
\u03C0
is equivalent to this:
π
and you can even use it in an identifier; these two are equivalent:
final String \u03C0 = "\u03C0";
final String π = "π";
(As the spec puts it:
A Unicode escape of the form
\u
xxxx, where xxxx is a hexadecimal value, represents the UTF-16 code unit whose encoding is xxxx. This translation step allows any program to be expressed using only ASCII characters.
See http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.2.)