saving . . . saved rules for variable names has been deleted. rules for variable names has been hidden .
rules for variable names
Title
Question
The tutorial states that variable names can start only with a letter or an underscore.
Any identifier in Java can start with a letter, a seperator(Underscore) or a currency symbol like $ or even \u20b9
letters can also be \u0a85 any letter from the Unicode character set.


Java Numerical-Datatypes 06-07 min 40-50 sec 29-01-19, 6:10 p.m. PravinJain

Answers:

The only allowed characters for java variables names are all alphanumeric characters, any currency symbol and underscore.
Variable names should not start with digits and java keywords can’t be used as variable names.
16-04-20, 8:05 a.m. srinivasrj129@gmail.com
What does alphanumeric mean? It gives an impression that only letters from (A-Z,a-z,0-9) are allowed.
Whereas what is allowed is any letter from the Unicode character set. eg. we can have a class called
\u0938\u0942\u091a\u0940(suchi in devanagari) having a method called \u092a\u094d\u0930\u0925\u092e (pratham in devanagari).


16-04-20, 10:30 a.m. PravinJain
You can also refer to https://books.google.co.in/books?id=lGRpeBZQYPoC&printsec=frontcover&dq=The+class+of+Java+by+pravin+jain&hl=en&sa=X&ved=0ahUKEwjVhOaVlezoAhV5ycQBHZN2BqAQ6AEIJzAA#v=onepage&q=The%20class%20of%20Java%20by%20pravin%20jain&f=false
section 3.2

16-04-20, 10:34 a.m. PravinJain

Login to add comment


1. Only allowed characters for java identifiers are a to z, A to Z, 0 to 9, _, $. If we are using any other character, compile time error will be thrown by compiler.<o:p></o:p>

2. Identifiers can’t start with digits.<o:p></o:p>

3. Java identifiers are case sensitive. Java language is considered as case sensitive programming language.<o:p></o:p>

4. There is no length limit for java identifiers, but it is not recommended to take too lengthy identifiers.<o:p></o:p>

5. We can’t use reserved word as identifiers.<o:p></o:p>

6. All predefined java class names and Interface names can be used as identifiers. Ex. String, Runnable. Even though it is valid, it is not good programming practice, as it reduces readability and creates confusion.<o:p></o:p>

01-05-20, 3:28 p.m. pankajap@cse.iitb.ac.in
Point 1 is incorrect. You can use Letters, Digits, Separator and Currency Symbol from the entire Unicode character set and not just ASCII.
Use of currency symbol \u20b9 indian Rupee symbol is also valid, so are all the letters and digits from all the other languages. eg. \u0905 the devenagari letter A is also valid, you can compile and check.
Java has good support for Unicode characters since the beginning and the size of char data type is 16-bit and not restricted to 8-bits as is the case in C.

01-05-20, 3:58 p.m. PravinJain

Login to add comment


Log-in to answer to this question.