Sometimes the classes that implement an interface are "secret." They're not public classes, and you're not supposed to call them by name.
The JDBC API is an excellent example of this. You call DriverManager.getConnection(String) to get a Connection object that lets you talk to a database based on the contents of that String. DriverManager is a class, and getConnection() is a static method of that class. But Connection is an interface. You do not know the name of the class that is returned. The DriverManager does something (conceptually) like this:
OracleConnection and MysqlConneection are classes that implement Connection. You do not and should not know their names or need to access them diretly.
When you call getStatement() on the Connection, the OracleConnection object would return an instance of OracleStatement, but you're just know that it was something that implemneted Statement, and that's all you'd need to know!
arraylist is implemetation of list interface.Then I can say,sun java ,by default given the implemetation?
Joined: Mar 22, 2005
Sometimes an API is defined in the expectation that the market will provide (one or more) implementations in due course. This is very rare, though, because without an implementation, an API can't be tested realistically. It may happen if an API is ported from another language to Java, though. JSAPI is the only one I can recall that at first didn't have an implementation. I think that APIs developed under the JCP are required to have at least two working implementations.
Then I can say,sun java ,by default given the implemetation?
For an interface defined in the Java class libraries this is generally true, but not always: JDBC is a good example. The only implementation shipped with the JRE is the JDBC/ODBC driver, which doesn't work on all operating systems (admittedly, this changed with Java 6, which does include a version of the Derby database and driver).