Java中使用Scanner接收输入的中文并输出时会出现乱码现象,怎么解决此问题呢?
在声明Scanner时添加对应的编码格式就可以了,如下所示:
Scanner sc = new Scanner(System.in, "UTF-8");
Run AS Configurations --> common -->将Console Encoding中编码改为GBK就可以了