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
Post a Comment