public class Dog{
String name;
public Dog(String name){
this.name=name;
}
public void sleep(){
System.out.println(this.name+“要睡觉啦!”);
}
}

public class B1{
public static void main(String… args){
Dog a=new Dog(“小黄”);
a.sleep();
}
}

这就是我用记事本写的一个小程序,直接编译就会出现如下错误
用记事本写Java中有中文,怎么用cmd输出中文
这个错误是因为字符编码错误引起的,所以我们只需要在编译时加上【-encoding UTF-8】就行,如下:
用记事本写Java中有中文,怎么用cmd输出中文

相关文章:

  • 2021-04-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
猜你喜欢
  • 2022-01-07
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案