File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class \u03a9\u03bb\u03c0 {} - a valid class name?

 
Nidhi Juneja
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found this question in Dan's exam

class \u03a9\u03bb\u03c0 {} // \u03a9\u03bb\u03c0=Ωλπ
if i run this and save the file by this name (exc the backslashs) i get
u03a9u03bbu03c0.java:1: class ??? is public, should be declared in a file named ???.java
public class \u03a9\u03bb\u03c0 {} // \u03a9\u03bb\u03c0=O?p
How is this a valid class declaration?
And If i run the unicodes seperately in a prog i get a '?' for each of the three and a '?' cannot be a part of a class name...is there another way to interpret this problem.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paste the following two class declarations into one file and compile it.

Invoke the main method of class A from the command line by typing "java A". The output will be "Omega lambda pi".
Although you might have a hard time typing Greek characters on your keyboard, you can still name a class using greek characters.
 
Nidhi Juneja
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan ..I tried running ur prog and this is what i get
--------------------------- Compiler Output ---------------------------
A.java:1: error while writing ???: ???.class (The system cannot find the file specified)
class \u03a9\u03bb\u03c0 { // \u03a9\u03bb\u03c0=Omega lambda pi
^
I am getting what u r trying to say but looking at this output.. does that mean my JVM doesnot support the version of Unicode which allows special characters and that's why it is unable to resolve // \u03a9\u03bb\u03c0=Omega lambda pi
and gives ???.
One thing more how is // \u03a9\u03bb\u03c0=Omega lambda pi in the comment helping the compiler to understand what we mean... i hope u understand what i mean to say
Thanks
Nidhi
 
Nidhi Juneja
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan ..I tried running ur prog and this is what i get
--------------------------- Compiler Output ---------------------------
A.java:1: error while writing ???: ???.class (The system cannot find the file specified)
class \u03a9\u03bb\u03c0 { // \u03a9\u03bb\u03c0=Omega lambda pi
^
I am getting what u r trying to say but looking at this output.. does that mean my JVM doesnot support the version of Unicode which allows special characters and that's why it is unable to resolve // \u03a9\u03bb\u03c0=Omega lambda pi
and gives ???.
One thing more how is // \u03a9\u03bb\u03c0=Omega lambda pi in the comment helping the compiler to understand what we mean... i hope u understand what i mean to say
Thanks
Nidhi
 
See El
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must have OS that doesn't support unicode or something, because the example works for me (Win2k, and the compiler did create a Ω?π.class).
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nidhi Juneja:

One thing more how is // \u03a9\u03bb\u03c0=Omega lambda pi in the comment helping the compiler to understand what we mean... i hope u understand what i mean to say
Thanks
Nidhi

The comment is not intended to provide information to the compiler. The comment is only there to make the program more readable for people.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nidhi Juneja:
Hi Dan ..I tried running ur prog and this is what i get
--------------------------- Compiler Output ---------------------------
A.java:1: error while writing ???: ???.class (The system cannot find the file specified)
class \u03a9\u03bb\u03c0 { // \u03a9\u03bb\u03c0=Omega lambda pi
^
I am getting what u r trying to say but looking at this output.. does that mean my JVM doesnot support the version of Unicode which allows special characters and that's why it is unable to resolve // \u03a9\u03bb\u03c0=Omega lambda pi
and gives ???.
Thanks
Nidhi

Section 3.8 of the Java Language Specification states the following.

Letters and digits may be drawn from the entire Unicode character set, which supports most writing scripts in use in the world today, including the large sets for Chinese, Japanese, and Korean. This allows programmers to use identifiers in their programs that are written in their native languages.
A "Java letter" is a character for which the method Character.isJavaIdentifierStart returns true. A "Java letter-or-digit" is a character for which the method Character.isJavaIdentifierPart returns true.

What operating system and JDK are you using?
 
Nidhi Juneja
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan ..thanx for the info ...i am using Windows ME and JDK 1.3
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nidhi Juneja:
Hi Dan ..thanx for the info ...i am using Windows ME and JDK 1.3

I'm surprised to see that Windows ME is not able to handle Unicode. It would be interesting to see if any other Windows ME users have a similar problem. It would even be more interesting to see some responses from users that have other operating systems.
I'm using Windows 2000 with JDK 1.4 and the code compiles and runs as expected.
Is anyone else out there willing to run the code example and post a response?
 
Jose Botella
Ranch Hand
Posts: 2120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked on WNT.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic