溫馨提示×

Java如何輸出中文

小億
1429
2023-08-09 21:12:25
欄目: 編程語言

Java中輸出中文可以使用以下兩種方法:

  1. 使用Unicode編碼。Java中的字符串是使用Unicode編碼的,可以直接在字符串中使用中文字符。例如:
public class Main {
public static void main(String[] args) {
String chinese = "你好,世界!";
System.out.println(chinese);
}
}

輸出結果為:“你好,世界!”

  1. 使用System.out的print方法輸出中文字符。System.out對象的print方法可以直接輸出字符串,包括中文字符。例如:
public class Main {
public static void main(String[] args) {
System.out.print("你好,世界!");
}
}

輸出結果為:“你好,世界!”

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女