Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new operator  RSS feed

 
aijazali chhachhar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why we donot use new operator for laoding drivers?why class.forname
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class.forName() doesn't return an instance, it initializes a class and returns a Class object.
Class Class (It is not a typo).

So why forName()?
Because it allows you to instantiate a class that you don't know until runtime, so your code is more dynamic.
 
Campbell Ritchie
Sheriff
Posts: 54608
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch aijazali chhachhar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!