Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Object creation in java

Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many objects are created when I run a simple HelloWorld Program shown below.

class HelloWorld
public static void main(String args[])

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?

author and iconoclast
Posts: 24203
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .

If you have specific questions about these classes, you could ask them here.
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic