Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 16th, 2007, 3:24 PM   #1
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
Naming Rules

I thought that the name of your class must be the same as the name of your project or file. I'm using JDeveloper and I just named a project "Gears of War." Then I named my class "GearsOfWarBaby", and I expected it to fail but it ran just fine. I don't get it.
357mag is offline   Reply With Quote
Old Jul 16th, 2007, 3:51 PM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
The code for a class must be in a file with the same name; eg, the code for the class GearsOfWarBaby must be in a file named GearsOfWarBaby.java. A project in an IDE such as JDeveloper may contain many such files.
titaniumdecoy is online now   Reply With Quote
Old Jul 16th, 2007, 6:23 PM   #3
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
Okay after expanding the nodes it looks like there is a file called GearsOfWarBaby that has a .java extension after it. That must be it then?
But it looks like I can name my program/project anything I want. I can even put a space between the words like Gears of War.
357mag is offline   Reply With Quote
Old Jul 16th, 2007, 6:55 PM   #4
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by 357mag
Okay after expanding the nodes it looks like there is a file called GearsOfWarBaby that has a .java extension after it. That must be it then?
Yup. The only rule is that your source file's name, before the .java extension, must exactly match the outermost class in that file. Of course, you can't have spaces or certain characters such as dashes; even though the file system might allow such characters, they are not allowed as part of Java symbols (including class names). Therefore, your file must match accordingly.
Quote:
Originally Posted by 357mag
But it looks like I can name my program/project anything I want. I can even put a space between the words like Gears of War.
The files associated with your IDE, such as project files, workspace files, configuration files (for the editor font size, tab distance, etc) have nothing to do with Java. You could erase them and compile your source files from the command line with javac.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New copyright rules. Indigno Coder's Corner Lounge 0 Nov 24th, 2006 6:49 AM
Designing business rules for a beautifier. nnxion Other Programming Languages 1 Feb 22nd, 2006 9:05 AM
Forum Rules big_k105 Community Announcements and Feedback 38 Sep 12th, 2005 7:05 PM
Firewall Script using IPTABLES Ravilj Bash / Shell Scripting 3 Mar 9th, 2005 9:09 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC