Hello,

I just discovered that we can use unicode anywhere in the program.

EG :

public class CheckUnicode {
	public static void m\u0061in(String\u005B\u005D args) {
		System.out.println("Hello World!");
	}
}

\u0061 = 'a' .. \u005B = ''

This program will execute fine without any errors.

But what i want to know is, Whats the benefit of using unicode in program ?

Waiting for your views and suggestions.

Regards,

You may need unicode to print characters that are not supported. Like having an application that needs to print messages in various languages (English, German, Chinese) depending on user's selection.

It is used for internationalization. In one of my projects we had different property files used for resource bundles to print messages in different languages. For languages like English, French we had normal characters, but for Chinese and others we used unicode.

Unicode is also used for printing unsupported characters in HTML pages

But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.

Meaning that you should name a method like:
> getNumberOfUsers

but not:
> epestrepseArithmoChriston

The later translates to the first method but you shouldn't name methods using your native language with english characters. Someone else might want to read the code.

It happened to me where we had to debug an entire application written in Italian. Not a clue what was going on. Babel Fish became my best friend

The ability to use any character regardless of the current system character set.

Be careful though. Unicode is translated as the first step in compilation, so you might wind up with some unforeseen complications.

See http://en.wikibooks.org/wiki/Programming:Java_Comments

commented: Thanks for the info! +2

Thanks for reply,
Ok, Got it.

So can we say, we use unicode in comments, method names and variable names to create a better documentation in native languages?

Or is there any other reason too ?

But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.

No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point to use unicode then

commented: Thanks for helping! +2

No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point to use unicode then

Yes, Thats what i actually wanted to say.

Thanks for help!

Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?

Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?

Well, maybe the people who write poetry in Perl (which then also must be functional code to qualify), yes, I can imagine. ;)

Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?

LOL, We will need to develop a special application to read and write applications in that such way. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.