Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName

 
Deena Raj
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between Class.forName and creating an object using new Abc()
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class.forName() loads a class. The "new" operator creates an instance of a class.
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class.forName() returns the "Class" object associated with ABC() and not a new instance of ABC().

For more details refer:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic