Why the need of java unicode when decimal representation is there? -


package test;  public class test {      public static void main(string[] args)  {        char b=65;        char b='\u0041';       //aren't these same?    }  } 

probably because native character set java programming language unicode , english not language in world.

programs written using unicode character set. © jls §3.1

in compiled java program char b = 65 , char b = '\u0041' produce absolutely equivalent bytecode. unicode escape sequence (\uxxxx) can used anywhere in source code, not in string or character literal definition, while number representation not.

short example:

public class helloworld {      public static void \u006d\u0061\u0069\u006e(string[] args) {         system.out.println("hello, world!");     }  } 

this absolutely correct "hello world" program main(string[] args) method. further reading: jls §3.2


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -