This problem occurs several solutions:
1, use javac to compile java files in cmd
Such as: javac test.java
The solution: add encoding options when compiling
javac -encoding UTF-8 test.java or javac -encoding UTF-8 -d . test.java
2 This error occurs when importing compile java file separate IntelliJ IDEA
Solution: As the IDEA does not have the automatic conversion character encoding types, so you need to click on the bottom right corner of the UTF-8 Save as type save GBK, GBK again click click save as UTF-8 can be.
3, use Notepad ++ to open the java file, click Encoding -> into ANSI encoding, save it.