• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Connection con;

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai members,
First of all thanking you to all of members to sending response to
my previous doubts.

actually Connection is a interface but we can write in this way

Connection con;
interface we cant create object;
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the question is?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Connection is an interface.With a reference of type Connection you would actually point to an implementation of Connection interface.
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Connection con;
interface we cant create object;

You are not creating an object in this statement,
You are declaring a variable con that can later hold an object that implements the interface Connection.

Later in your code, you will not use: con = new Connection(), but something else.
What are you doing: you are asking your database driver to give you an object that implements the Connection interface.

It's a good idea to set a breakpoint in this line of code, and see what class this object actually is.

Regards, Jan

[corrected my typo: Connection class - doh]
[ August 27, 2007: Message edited by: Jan Cumps ]
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic