Scanner in = new Scanner(System.in,"UTF-8");
System.out.println(in.next());
If I paste ∧
, I receive ?
as output to the console. Can someone explain what I can do to properly read logic symbols like this? I'm using NetBeans 8.0.1.
Thanks.
The problem is not with entering the character, but rather with printing it to console. Your console does not appear to support the code point \u2227
of ∧
, so it prints a question mark instead.
You should test if console lets you input ∧
correctly by printing the numeric representation of the character that you read, like this:
Scanner in = new Scanner(System.in,"UTF-8");
String s = in.next();
if (s.length() != 0) {
System.out.println((int)s.charAt(0));
}
If 8743
gets printed, you could process the character internally: comparisons like this
if (s.equals("∧")) {
...
}
will work correctly.
Otherwise, you should switch to using characters from the first code page, i.e. ^
instead of ∧
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With