Home > Software design >  Java print "?" instead of the thing
Java print "?" instead of the thing

Time:10-31


public class javaClass {
    public static void main(String [] arg) {
        String row1 = "A____A";
        String row2 = "|・ㅅ・|";
        String row3 = "|っ c|";
        String row4 = "|   |";
        String row5 = "|   |";
        String row6 = "U ̄ ̄U";
          
        
        System.out.println(row1);
        System.out.println(row2);
        System.out.println(row3);
        System.out.println(row4);
        System.out.println(row5);
        System.out.println(row6);
    }
}

I was trying to print out the drawing when running the code in my windows command prompt, but it print out;

A____A
|???|
|???|
|???|
|???|
U??U

what I am doing wrong? new to Java

CodePudding user response:

This is the behavior of your windows command prompt text encoding.
One quick workaround is to switch the font of your command prompt to something that accepts these non-english characters.

eg.

This text: default

Becomes this: enter image description here

When I change the properties > font from "Consolas" to "MS Gothic" enter image description here

enter image description here

  • Related