Results 1 to 5 of 5
- 07-29-2010, 07:43 AM #1
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:
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.public interface Set {
public Set union(Set S);public void add(Object x);}
- 07-29-2010, 08:00 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
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.
- 07-29-2010, 08:19 AM #3
So I have this code below:
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.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();
}
}
- 07-29-2010, 09:46 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
You know what your requirements are...we don't.
On top of that we aren't going to write this for you.
- 07-29-2010, 01:42 PM #5
Similar Threads
-
Implementing Interface
By mew in forum New To JavaReplies: 4Last Post: 02-16-2010, 03:33 PM -
help! implementing an interface
By manda147 in forum New To JavaReplies: 28Last Post: 11-17-2008, 04:27 AM -
Implementing an interface
By bugger in forum Advanced JavaReplies: 1Last Post: 01-09-2008, 01:35 PM -
Implementing Serializable interface
By javaplus in forum Advanced JavaReplies: 4Last Post: 12-18-2007, 12:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks