I'd like to apologize upfront for my incredible newb-ness with regard to Java and programming in general. But I've searched everywhere for an answer to this and I just can't seem to find one.
So I'm simply trying to run the following:
public class WriteSquares2
{
public static void main(String[] args)
{
for (int i=1; i<=10; i++)
{
System.out.println(i + " \u2261 " + (i % 7) + " modulo 7");
}
}
}
The Unicode character \u2261 is the congruence sign (≡). DrJava shows the following as output:
1 ? 1 modulo 7
2 ? 2 modulo 7
3 ? 3 modulo 7
4 ? 4 modulo 7
5 ? 5 modulo 7
6 ? 6 modulo 7
7 ? 0 modulo 7
8 ? 1 modulo 7
9 ? 2 modulo 7
10 ? 3 modulo 7
What's weirdest about this is that when I simply type
'\u2261'
into the Interactions box, I get the equivalence character in single quotes:
'≡'
I've tried simply putting '\u2261' in the code instead of " \u2261 ", but then I get stuff like this:
8803 modulo 7
8805 modulo 7
8807 modulo 7
I also tried just simply inserting the unicode character into the code, but that just gave an error message. Can anyone figure out what's going on or what I'm doing wrong? Your help is much appreciated.
[I should add that this isn't a homework assignment or anything, as our book barely even mentions Unicode - just trying to figure this out ... and when I started, I didn't think it would be this hard!]
EDIT: I'm using Mac OS 10.7.5 and Dr Java says its build is "drjava-20120818-r5686".
EDIT #2: Here's a screenshot using Monospaced 12 as my main font. It still shows up as question marks, even though I can get the console to return me the symbol if I type it in directly, but with single quotes.
?
. Check your code page bychcp
. Under Unix, similarly, it is affected by the locale settings. Check the LANG (do I remember it right?) env variable to make sure that the encoding contains the char you need – Iaria