Class.forName(), takes the class name as parameter, and loads that class in memory. But it doesn't create any instance of that class.
That means static methods/variables are available for use.
new keyword, checks if the class is loaded, if not then loads that class, and then creates an instance of that class.
> Class.forName(), takes the class name as parameter,
> and loads that class in memory. But it doesn't create
> any instance of that class.
> That means static methods/variables are available for
> use.
>
> new keyword, checks if the class is loaded, if not
> then loads that class, and then creates an instance
> of that class.
Class.forName actually returns the class object for that name (class - for -name). it might load it, if the class hasn't already been loaded, but it's misleading to say that's what that method does
your definition of 'new' is wrong, too. give the dukes back
> > your definition of 'new' is wrong, too. give the
> > dukes back
>
> :) I think this is a nice example "correct is what I
> want to hear".
I have an inkling - but I'm far from sure - that they're the same person, bumping their dukes score up
>I have an inkling - but I'm far from sure - that they're the same person, bumping their dukes score up
This is the forum where I learnt a lot!!! I can't cheat with it.
If you think so, then I am returning back my duke dollers in an empty post.
I will award it to you, you just reply to that post.
and I answered what I knew, and I thank you all for updating my knowledge.
But please correct my answer about new keyword.
I have no interest in duke dollars. give 'em back to the OP. you're probably not the same person
new doesn't have anything to do with loading classes, it just asks the JVM for a new instance of a class. if the JVM needs to load that class, it does so. but really, the difference between 'new' and Class.forName is that they are entirely different mechanisms in the language, like Object.equals and interfaces