One java source file generate one .class byte code file ?
False.
I thought one java source code file will generate only one .class byte code file, since I am a c++ programmer for about 10 years.
The correct answer is
how many classes defined in java source, how many .class byte code files will be generated after compile via javac
public class HelloWorld {
class HelloInternal {
}
}
enum HelloEnum {
}
interface HelloInterface {
}
javac HelloWorld.java
ls *.class
HelloEnum.class HelloWorld$HelloInternal.class
HelloInterface.class HelloWorld.class
I thought one java source code file will generate only one .class byte code file, since I am a c++ programmer for about 10 years.
how many classes defined in java source, how many .class byte code files will be generated after compile via javac
javac HelloWorld.java
Java classes
The classes can be any class, interface and enum.
All java codes should be placed in the classes.
otherwise you will get compile error
class, interface, or enum expected
In fact, enum is a class too, just a syntactic sugar.
All java codes should be placed in the classes.
otherwise you will get compile error
class, interface, or enum expected