Book category:
Public books {
Private string name;
Private string publishing;
Public string getName() {
Returns the name;
}
Public void setName {
this.name = name
}
Public string getPublish() {
Return to publication;
}
Public void setPublish (
this.publish = publish
}
Public book (string name, string publishing) (
super();
this.name = name
this.publish = publish
}
Public books () {
}
}
Test category:
Public class test manual {
Public static void main(String[] args) {
Book Book 1 = new books (Data Structure, Higher Education);
Book book2 = new book (Operating System, Electronic Industry Press);
Book book3 = new book (Java, Electronic Industry Press);
Book book4 = new book (Data Structure, Tsinghua University Publishing House);
Collection & ltBook & gtc 1 = new array list & lt& gt ();
Collection & ltBook & gtc2 = new array list & lt& gt ();
Collection & ltBook & gtc3 = new array list & lt& gt ();
c 1 . add(book 1);
c 1 . add(book2);
C 1.add (Volume III);
C2.add (Volume II);
C2.add (Volume IV);
Boolean cont = false
for(Book book:c 1){
if(book.getName()。 equals(" Java ")& amp; & ampBook.getPublish()。 Equal to ("Machinery Industry Press") (
cont = true
}
}
System.out.println (continued);
For (Book book02:c2){
Boolean a = true;
for(Book Book 0 1:c 1){
if(book0 1.getName()。 equals(book 02 . getname())& amp; & ampbook0 1.getPublish()。 equals(book 02 . get publish()){
A = false;
}
}
If (a){
C3 . add(book 02);
}
}
For (Book B: C3) (
c 1 . add(b);
}
Iterator & lt book & gt iterator = c1.iterator ();
while(iterator.hasNext()){
book b = iterator . next();
system . out . println(" Title:"+b . getname());
system . out . println(" publisher:"+b . get publish());
}
}
}