Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable declaration in java

 
saravana sankar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai everyone,

In java I was surprised by the following coding.

class c1
{
public static void main(String a[])
{
int �;
� = 10;
System.out.println("The value is : " +�);
}
}
I thought that this will give an error but it is getting excecuted normally.
Any variable should start with an alphabet
or underscore or currrency.
But I am surprised to see that
the value between Alt-128 to Alt-158 also comes under this
category.
so pls. give explanation.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with Java News so I will move this to... hmmmm....
Java In Genral (Intermediate).
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An identifier (variable) should start with a letter - including underscore (_) or dollar sign ($) - followed by letters or digits.
A "letter" uses the unicode definition, which includes lots of characters from many languages.
See javadoc for Character.isJavaIdentifierStart()
or the JLS section about identifiers
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic