java 变量名 字符串,在JAVA变量名称中使用UTF-8字符

I would like to know that can I use my native language characters (or String) as JAVA variable names ?

So, I had tested as below with Myanmar Unicode.

public static void main(final String[] args) {

String ဆဆဆ = "မောင်မောင်";

System.out.println("ကောင်းသောနေ.ပါ " + ဆဆဆ);

}

This code show my successful message as 'ကောင်းသောနေ.ပါ မောင်မောင်'. But in below code with another variable name (it also my native language String).....

public static void main(final String[] args) {

String တက်စတင်း = "မောင်မောင်";

System.out.println("ကောင်းသောနေ.ပါ " + တက်စတင်း);

}

that produce compile time error in my Ecliplse IDE.

Multiple markers at this line

- Syntax error on tokens, delete these tokens

- Got an exception - Unexpected character 0x103a in

identifier

Any suggestion ? Why would this problem has occured ? Thanks for reading my question patiently.......

解决方案

Java 6 merely supports Unicode 4.0, a quite old version of Unicode which doesn't include Myanmar (or at least only rudimentary). Extended Myanmar support was added to Unicode 5.1, which is supported in Java 7.

To resolve this issue, install JDK 7 if you haven't already, and configure your Eclipse project to compile as Java 7 (Project->Properties->Java Compiler). Please note that code compiled as Java 7 cannot be run on Java 6 or lower.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值