开发者

adding another set Strings to TreeSet - java

I have a public method (called getMusic) in a class called Favorites. getMusic has set. There are 3 sets and in each set has five words, Set getMusic(). In another class called myInterest, there is a treeSet called musicTable. I called getMusic method into myInterest class but I do not know how to iterate over so that 开发者_StackOverflowthe set of words can be added to musicTable TreeSet. I tried to use addAll but it's not working. Where I am going wrong and how do I fix this? .I don't want to use list, I've thought about for loop but not to sure how to use this or literate(). thank you

public class myInterest
{

  private static TreeSet<String> musicTable = new TreeSet<String>();  

  public Test()
   {
     super();
     musicTable = new TreeSet<String>();
   }


  public static void testOut()
  {

    Favorites entrainment = new Favorites(); 

    System.out.println(" " + entrainment.getMusic());

    entrainment.addAll(musicTable); //error msg "cannot find symbol - method addAll(java.util.TreeSet<java.lang.String>)

    musicTable.addAll(entrainment); //also tried this way but error msg "cannot find symbol - method addAll(Favorities) 
  }

}


Do you mean:

musicTable.addAll(entrainment.getMusic());

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜