this is for our own convenience.
actually that depends on ur IDE u r using.
suppose u r developing an application having thousands of classes.
if ur IDE allowed to have multiple classes with in a single java file .....then third party having ur packages will take time to analyze the package structure and all the java files.
so this is not desirable in Software Developement.
i think u got my point of view.
This is nothing but programming convenience.
Hi,
Why we are always give the program name same as class name?
Thanks,
Srinivasan r
I'm not sure what you mean by program name. If you mean java file name (just a guess) then it's not neccessary to give it the same name as the name of the class(es) that is/are in it. However, if you have a public class in a Java file, then it must be the only public class there and the name of the file must be the same as the name of that public class
If you have a public class A that refers to another public class B, javac needs
the compiled version of class B when it compiles class A. If it can find a B.class
file (either in the filing system, or a jar) if uses that file to check for correctness
of class A (which it is compiling). When B.class is outdated, it needs to be
recompiled. The only way javac can find the source file for class B is by its
name: B.java. If it finds it it recompiles B.java to check whether or not A.java is
correct. If class B where allowed to be stored in anything else but B.java, javac
wouldn't be able to find it.
The need for class X be stored in a file X.java is purely a compiler technicality.
If a compiled class X.class has a modification time stamp older than the
modification time stamp of the X.java source file then the X.class file is
outdated and X.java needs to be recompiled. The javac compiler does that all
behind your back, i.e. it has a simple 'make' like functionality.
i m working with J2EE technolgy for one year.
i have confusion right now .... does J2EE framework contain JAVAC?
how the web-container compiles a servlet file?
so here the javac required.
so if i change a .java file then we need not to recompile the java file if my servlet refers to that .java file.
but i need to recomile the .java file.
now the total thing is mess up.
plz help.
kind regards.
Comment