Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By JosAH

Thread: Java Interface

  1. #1
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default Java Interface

    The first language that i was exposed to was c++. As a result when i see the term interface i think of it has separating the implementation of my classes from the presentation which the user of the class will interact. However when i started using java i realized this is not the case. Can Someone really explain the concept of interface in java for me and tell me a common application of it.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Java Interface

    See:
    java.util.Collection
    java.util.List (etc etc)
    java.sql.Driver
    java.sql.Statement (etc etc)

    It defines the contract that any implementing class will provide, allowing someone to change the underlying concrete class without changing the code that uses that interface. For the sql ones above, each db vendor has their own implementation of those classes, but I (as a generic JDBC user) don't care because I am simply coding against those interfaces, not the implementation of them.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Interface

    Quote Originally Posted by mDennis10 View Post
    The first language that i was exposed to was c++. As a result when i see the term interface i think of it has separating the implementation of my classes from the presentation which the user of the class will interact. However when i started using java i realized this is not the case. Can Someone really explain the concept of interface in java for me and tell me a common application of it.
    In C++ terms: a Java interface is a class with only abstract virtual functions. C++ doesn't have a separate keyword for the thing.

    kind regards,

    Jos
    sunde887 likes this.
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default Re: Java Interface

    thanks alot for the help

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Java Interface

    Spam reported, especially since it was echoing me!

Similar Threads

  1. Interface in Java
    By JAVA03 in forum New To Java
    Replies: 2
    Last Post: 03-03-2011, 07:22 AM
  2. Java app without interface
    By fawzan in forum Advanced Java
    Replies: 9
    Last Post: 12-29-2010, 04:07 PM
  3. Replies: 1
    Last Post: 05-31-2009, 10:57 PM
  4. Replies: 1
    Last Post: 05-31-2009, 02:17 PM
  5. Replies: 16
    Last Post: 05-28-2009, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •