Monday, March 22, 2010

Unicode variable names in Java

Total I learned that you can have Unicode characters in your class/variable names.

public class Lang
{
 public static final int प्रियानंद  = 42;
 public static final int ಪ್ರಿಯಾನನ್ದ = 33;

 public static int ನನ್ನ(int x)
 {
  return x + 1;
 }
 public static int ಹೆಸರು(int x)
 {
  return x - 1;
 }
 public static void main(String [] args)
 {
  ನನ್ನ(ಹೆಸರು(ಪ್ರಿಯಾನನ್ದ));
 }
}

Note: You might have to specify -encoding Unicode when compiling.

1 comment:

MYSTERY OF MY SPIRIT said...

kewl !!!!

I had to use -encoding UTF-16 though :-)