aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes static char in the files given from Sun Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "static char in the files given from Sun" Watch "static char in the files given from Sun" New topic
Author

static char in the files given from Sun

John Chien
Ranch Hand

Joined: Feb 06, 2003
Posts: 105
Hi,
I was given several files as part of initial assignment from Sun. When I read the codes, I found that there is a static data member in each of the Data, DataInfo, and FieldInfo classes.
The static data member is:
final static char sc = 'A';
I could not find the use of it in the programs given. I am wondering if anybody receives the same kind of code as me. Can anybody can tell me what it is used for ? Can I ignore it when I implement the code change ?
Thanks,
John Chien


SCJP, SCJD, SCWCD, SCBCD<br />IBM Certified Specialist (158)<br />Oracle9i PL/SQL Developer Certified Associate
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
You can ignore it. You can even take it out.
Also, there are two issues with this field:
1) It is suggested (but not required) in the Java Lang Spec that it should be static final, not final static.
2) It is required in the JLS that static final fields should not be named with lowercase letters.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

2) It is required in the JLS that static final fields should not be named with lowercase letters.

Well, it's not really required, and it's not in JLS, but in Java Coding Conventions. Just to make it clear...
Eugene.
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Originally posted by Eugene Kononov:

Well, it's not really required, and it's not in JLS, but in Java Coding Conventions. Just to make it clear...
Eugene.

Eugene -
Did you check the spec? It "clearly" says it right here:
JLS Naming of Constants
In both the JLS and the Conventions docs they refer to it as a convention. I would follow it just as you probably follow the suggestions for method and class naming. If you do follow some other convention, I would make sure that it is consistently followed throughout all of your code. (i.e. - if you leave that constant as "sc", then don't use the Sun convention everywhere else)
-BJ
[ February 20, 2003: Message edited by: BJ Grau ]
John Chien
Ranch Hand

Joined: Feb 06, 2003
Posts: 105
Thanks. Now, I get the idea.
I asked the same question to Sun. They won't tell me anything about it.
John Chien
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

Did you check the spec? It "clearly" says it right here:

I followed your link, and there two clauses there regarding the use of uppercase letters in constants:
"The names of constants in interface types should be, and final variables of class types may conventionally be (my emphasis), a sequence of one or more words, acronyms, or abbreviations, all uppercase, with components separated by underscore "_" characters."
"Constant names normally (my emphasis again) have no lowercase letters, so they will not normally obscure names of packages or types, nor will they normally shadow fields, whose names typically contain at least one lowercase letter.
So it is certailnly not a requirement, rather a convention. After all, if it compiles, then it conforms to JLS. But let's not argue about it, -- of course one should follow the conventions.
Eugene.
[ February 20, 2003: Message edited by: Eugene Kononov ]
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Good point. There is a big difference between a requirement and a convention. I noticed the error after my first post and tried to clarify by saying they refer to it as a convention. I hope I didn't mislead anyone.
Interestingly enough, I was looking for something in the 1.2.2 source today and noticed that there is no 100% consistent application of a naming style for constants, so perhaps the whole point is moot anyway.
I don't think anyone's arguing, we're just having a healthy discussion on the smaller details of style.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static char in the files given from Sun