• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple loading of a class thru Class.forName() ??

 
Mahendra Shelke
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers ,

Does a class gets loaded twice in the memory if i call it twice in my code using Class.forName() ?



will this load the driver in the memory twice or do i have take care of it using a static block ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class will only be loaded once. As long as the second one asks the same ClassLoader to load the Class, nothing will happen. It is however possible for the class to be loaded if another ClassLoader is specified, but not guaranteed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic