Topic: 看看这个例子,难道java支持中文变量名?

  Print this page

1.看看这个例子,难道java支持中文变量名? Copy to clipboard
Posted by: 土妞
Posted on: 2005-04-21 20:57

public class Test{

void print(String 中文)
{System.out.println(中文 );}

public static void main(String args[])
{Test tt=new Test();
tt.("Hello World");
}
}
这个程序居然能运行,太奇怪了,难道java支持中文变量名?

2.Re:看看这个例子,难道java支持中文变量名? [Re: 土妞] Copy to clipboard
Posted by: bluepure
Posted on: 2005-04-21 20:59

好像使用UTF-8就可以的。

不过一般没有人敢用,编码问题一出,直接疯掉。呵呵

3.Re:看看这个例子,难道java支持中文变量名? [Re: 土妞] Copy to clipboard
Posted by: aphle
Posted on: 2005-04-22 18:05

为什么我连这个都运行不了???

import java.io.*;
public class testCn {
  void print(String e){
    System.out.println( e );
  }
  public static void main(String args[]){
    testCn outSUN = new testCn();
    outSUN("hello sun");
  }
}

4.Re:看看这个例子,难道java支持中文变量名? [Re: 土妞] Copy to clipboard
Posted by: 土妞
Posted on: 2005-04-23 15:47

不好意思,我打错字了,程序的最后一句应该改为
tt.print("hello world");

5.Re:看看这个例子,难道java支持中文变量名? [Re: 土妞] Copy to clipboard
Posted by: 笨蛋的笨蛋
Posted on: 2005-04-24 08:11

就是,我看着还以为这样都能运行?!!

6.Re:看看这个例子,难道java支持中文变量名? [Re: 土妞] Copy to clipboard
Posted by: aroundall
Posted on: 2005-04-24 23:09

应该是支持的哦,Unicode


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923