| Author |
Object creation in java
|
rajaraman navaneethan
Ranch Hand
Joined: Feb 26, 2005
Posts: 86
|
|
Hi, How many objects are created when I run a simple HelloWorld Program shown below. class HelloWorld { public static void main(String args[]) { System.out.println("HelloWorld"); } } Is java.lang.Class instance created for this class?If so, when is it created? Can anyone please give me a good link which would help me understand java.lang.Class? regards, Raja
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
None of the code here explicitly or implicitly creates any objects. But JVM startup creates hundreds, and then loading your class and invoking your application creates more (the java.lang.Class object, of course, and some indeterminate number of subordinate objects, and a String[] to pass as an argument to main() ). This question is really very vague; you have to be more specific as to which objects should be included, and even then, lots of what happens is implementation-specific. As far as java.lang.Class: the JVM creates a class object in the process of loading a class into the JVM. You can read the Javadocs for java.lang.Class and java.lang.Classloader to get an introduction to these classes; otherwise, the Java VM spec is the place to go for detailed information. See http://java.sun.com/docs/books/jvms/ . If you have specific questions about these classes, you could ask them here.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Object creation in java
|
|
|