View Full Version : Basic question for java
prajwala
05-25-2007, 05:10 AM
if my filename is not matching with the class name then will my program compile? or will give me an error?
Thanks in advance
Can u suggest me to refer the sites for learning java?
If your class is named MyProgram (i.e public class MyProgram), then the filename for your class needs to be named MyProgram.java.
If you don't follow this rule you should get a compilation error similar to the following
>>class MyProgram is public, should be declared in a file named MyProgram.java
Basic Java tutorials:
http://java.sun.com/docs/books/tutorial/
prajwala
05-25-2007, 06:49 AM
If your class is named MyProgram (i.e public class MyProgram), then the filename for your class needs to be named MyProgram.java.
If you don't follow this rule you should get a compilation error similar to the following
>>class MyProgram is public, should be declared in a file named MyProgram.java
Basic Java tutorials:
http://java.sun.com/docs/books/tutorial/
Thanks for your help :)
ghell
05-25-2007, 11:33 PM
Java represents public classes with files and packages with directories. java.lang.String would be in /java/lang/String.java. If you give it the wrong name, it can't find it :)
prajwala
06-15-2007, 08:00 AM
Thanks for giving me such a usefull information :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.