GIDForums

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-May-2008, 00:46
fred fred is offline
New Member
 
Join Date: Apr 2008
Posts: 3
fred is on a distinguished road
Thumbs down

java


Hello guys I would be more than grateful if I got the answers to the following questions
1) What happens if you change the name of the source code file e.g ''helloearth.java instead of helloworld.java?
2) What happens if you keep the name of the source code file the same e.g "helloworld.java" but change the class name e.g class helloearth.
  #2  
Old 08-May-2008, 07:10
JustinFox JustinFox is offline
New Member
 
Join Date: Mar 2008
Posts: 26
JustinFox is on a distinguished road

Re: java


Quote:
Originally Posted by fred
Hello guys I would be more than grateful if I got the answers to the following questions
1) What happens if you change the name of the source code file e.g ''helloearth.java instead of helloworld.java?
2) What happens if you keep the name of the source code file the same e.g "helloworld.java" but change the class name e.g class helloearth.

If you change the name of the source code file to a different name then you must change the name of the outer most class to the same thing.

Javac relates your filename to your class name in order to compile correctly. This is because everything is Object Oriented. It's not like C, where you can have any name you want for your file, because C doesn't implement classes and such.

And by Object oriented, I mean super-OO, I mean the root class in java is Object, everything extends from this class.

I don't know the exact reason why you have to have the source code file and class name the same, as in compiler structure and interpretations, but I do know that it just needs to be done.

Justin Fox
 

Recent GIDBlogGoing to Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB 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
C code to Java bengt23648 Java Forum 2 09-Sep-2007 05:33
What is the equivalent in Java for a Function or Module in VB pengwinz Java Forum 2 17-May-2007 20:02
To post messages / click Buttons of a Java Jar App using code Jun0 C Programming Language 1 06-Jan-2007 14:44
To post messages / click Buttons of a Java Jar App using code Jun0 Java Forum 0 06-Jan-2007 11:14
Scalability in Java and C++ agx Miscellaneous Programming Forum 7 04-Feb-2006 15:35

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:58.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.