In my book I read following:
import java.io.Console;
// better to print thro' Console object - it handles "special characters" better
class SpecialCharHandling {
public static void main(String []args) {
// string has three Scandinavian characters
String scandString = "å, ä, and ö";
// try printing scandinavian characters directly with println
System.out.println("Printing scands directly with println: " + scandString);
// now, get the Console object and print scand characters thro' that
Console console = System.console();
console.printf("Printing scands thro' console's printf method: " + scandString);
}
}
Here is what this program prints: Printing scands directly with
Printing scands directly with println: •, •, and ÷
Printing scands thro' console's printf method: å, ä, and ö
As you can see from this output, Console’s printf() method (and other methods) have better support for special characters.
I try to launch this application locally. I got a different result:
Printing scands directly with println: ├е, ├д, and ├╢
Printing scands thro' console's printf method: Г?, Г¤, and Г?
How to explain difference with book ?