David Antelo
David Antelo

Reputation: 533

Java can't handle π character

Reduced version of my current problem: I'm trying to print the character π in java, but when I do:

System.out.println("π");

All I get in the console is a question mark. I don't know why this happens and I haven't been able to fix it, hopefully someone will know how to. Thanks

Upvotes: 0

Views: 237

Answers (2)

tobsob
tobsob

Reputation: 602

Make sure that your source code is writen in UTF-8.

You can also use a UNICODE constant directly, like this:

System.out.println("\u03C0");

Upvotes: 1

Kurt Harrison
Kurt Harrison

Reputation: 25

You could use the escape character \u03C0. This stackoverflow post is the same question.

Upvotes: 1

Related Questions