How to write "Ni Hao" ("Hello") in Chinese to standard output using UTF-8 in Java

1 Answer

0 votes
import java.nio.charset.StandardCharsets;

public class HelloUnicode {
    public static void main(String[] args) {
        // Ensure console uses UTF-8 (most modern terminals do by default)
        System.out.println("你好");
    }
}


 
 
/*
run:
 
[1, 2, 6, 7, 8]
 
*/

 



answered Aug 14, 2025 by avibootz
...