0

Hello, I am trying to return the union of two ArraySet Strings as a third; however, the compiler is complaining:

found : jss2.SetADT<java.lang.String>
required: jss2.ArraySet<java.lang.String>
union = one.union(two);

I was thinking I could pass an ArraySet<String> as the parameter but unfortunetly I am stuck here. Any suggestions on how to get this one.union(two) assigned to un? I've attatched the jss2 package to the thread.

import jss2.*;
import java.util.*;


public class Hw8p2 {
	 
	 public static void main (String[] args) { 
	
	 ArraySet<String> one = new ArraySet<String>();
	 ArraySet<String> two = new ArraySet<String>();
	 ArraySet<String> un = new ArraySet<String>();
	 String s_one_1 = "one";
	 String s_one_2 = "two";
	 String s_one_3 = "three";
	 one.add(s_one_1);
	 one.add(s_one_2);
	 one.add(s_one_3);
	 String s_two_1 = "four";
	 String s_two_2 = "five";
	 String s_two_3 = "six";
	 two.add(s_two_1);
	 two.add(s_two_2);
	 two.add(s_two_3);
	 System.out.println(one);
	 System.out.println(two);
	 
          un = one.union(two);
 
	 }
}
Attachments
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kezkez
0

many thanks, i was casting all wrong before with un = one.union((ArraySet<String>)two);

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.