File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Questions on naming convention Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Questions on naming convention" Watch "Questions on naming convention" New topic
Author

Questions on naming convention

shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
1) Is there any reason for # being illegal in identifiers like - int e#. Is # used for anything else?

2) What is the keyword throw used for?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

I'm not aware of '#' specifically used anywhere else right now, but that is not to say it won't be used for something someday.

'throw' is used to pass an exception up to the calling method. Look up "exception handling" or just "exceptions", and it should give you detailed info on it.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Daniel Marti
Ranch Hand

Joined: Jun 08, 2011
Posts: 37
1) I believe the reason for this one is pure convention. Java does not use # for anything, at least that i can remember or see in common documentation.

2) Throw is used to launch an exception. Is different than throws, which means that your method can throw an exception.

Example:
shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
Fred,Daniel thanks. I came across one more keyword const. Looks like this is similar to final But with const the object value will not change. Am I right
Daniel Marti
Ranch Hand

Joined: Jun 08, 2011
Posts: 37
There is no const in java.
You can use the keyword "final" for generally the same effect only in primitive variables!
For objects you can create a new Object that is a clone of the object passed as parameter.
Example:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36482
    
  16
There is a keyword const in Java™. But it is never used.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36482
    
  16
The behaviour you are describing sounds more like the behaviour of const in C.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

Daniel Marti wrote:
You can use the keyword "final" for generally the same effect only in primitive variables!

final still applies to reference variables. But it just means the reference cannot change, not that the object it's pointing at can't change (unless it's an immutable object).
Daniel Marti
Ranch Hand

Joined: Jun 08, 2011
Posts: 37
Campbell Ritchie wrote:There is a keyword const in Java™. But it is never used.

I stand corrected. There is a const keyword. Have to say it surprises me that i never even heard of it, not even in very boring and very extensive theoretical java classes(college)... Live and learn!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions on naming convention
 
Similar Threads
catching errors on inserts into multiple tables
Do you like twitter ?
java unable to recognize class where my IDE does
what is weblogic clusters?where is it used?
Difference between const & final in java ?