File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface probelm?

 
harsh garg
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we all know we cannot create the object for the interface,But during the database connectivity , we create the object for the interface...


Connection con;
Statement st;
Class.forName(driver);
con=DriverManager.getConnection("");



here how is possible?

 
Maneesh Godbole
Saloon Keeper
Posts: 10976
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same way we can create


Actually what you are creating (by calling new) is a HashSet type of object, but since it is of the type Set, the above statement is legal.
 
amitabh mehra
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always assign object of child type into reference of parent type.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic