Results 1 to 5 of 5
  1. #1
    yel_hiei's Avatar
    yel_hiei is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default Need Urgent Help in Implementing Interface Class

    Hi I'm new to Java and I badly need help on how to implement the Set interface below:

    public interface Set {
    public Set union(Set S);
    public void add(Object x);
    }
    Can you show me the simplest way in implementing the interface. Any method would do... I just need to be able to add values to a Set and implement a union on a Set. Thanks much.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Yeah, use the implements keyword and then define methods in the class that match those defined in the interface, of course.

    There is only one way of implementing an interface, you know. See the tutorials.

  3. #3
    yel_hiei's Avatar
    yel_hiei is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    So I have this code below:

    public class Test implements Set{

    public Set union (Set A){

    }

    public void add(Object x){

    }

    public static void main (String args[]){

    Set A = new MySet();


    }

    }
    Can you help me on how public void add(Object x) should be implemented? I really don't have an idea on how to use this method to add values to the Set. Thanks much.

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

    Default

    You know what your requirements are...we don't.

    On top of that we aren't going to write this for you.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

Similar Threads

  1. Implementing Interface
    By mew in forum New To Java
    Replies: 4
    Last Post: 02-16-2010, 03:33 PM
  2. help! implementing an interface
    By manda147 in forum New To Java
    Replies: 28
    Last Post: 11-17-2008, 04:27 AM
  3. Implementing an interface
    By bugger in forum Advanced Java
    Replies: 1
    Last Post: 01-09-2008, 01:35 PM
  4. Implementing Serializable interface
    By javaplus in forum Advanced Java
    Replies: 4
    Last Post: 12-18-2007, 12:29 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
  •