File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes class \u03a9\u03bb\u03c0 {}  - a valid class name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "class \u03a9\u03bb\u03c0 {}  - a valid class name?" Watch "class \u03a9\u03bb\u03c0 {}  - a valid class name?" New topic
Author

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

Nidhi Juneja
Greenhorn

Joined: Oct 07, 2002
Posts: 27
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

Joined: Jul 02, 2002
Posts: 1865
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.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Nidhi Juneja
Greenhorn

Joined: Oct 07, 2002
Posts: 27
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

Joined: Oct 07, 2002
Posts: 27
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

Joined: Oct 07, 2002
Posts: 44
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).


See El<br />SCJP2, SCWCD, IBM XML, SCBCD
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
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

Joined: Jul 02, 2002
Posts: 1865
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

Joined: Oct 07, 2002
Posts: 27
Hi Dan ..thanx for the info ...i am using Windows ME and JDK 1.3
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
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

Joined: Jul 03, 2001
Posts: 2120
It worked on WNT.


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class \u03a9\u03bb\u03c0 {} - a valid class name?