//Set的特点:唯一(元素不相同);无序 case class Book(var bookName:String,var author:String,var price:Double){} object test27 {def main(args: Array[String]): Unit = {//定义一个可变setval set1 = scala.collection.mutable.Set[Book]()//向Set中添加两条一样的数据val book1 = new Book("西游记","吴承恩",99)val book2 = new Book("西游记","吴承恩",99)val book3 = new Book("西游记","吴承恩",99)//book1 == book2?println(book1 == book2) // false 因为 book1和book2 地址不同set1 += book1set1 += book2set1 += book3set1.foreach(s=>{println(s.author)})} }