首页 > 其他分享 >2022.12.17

2022.12.17

时间:2022-12-17 23:01:12浏览次数:38  
标签:Book return 17 int list book public 2022.12

 /**      * 查询--根据图书名称查询图书信息      * @param name      */     public Book query(String name){         for (int i = 0; i < list.size(); i++) {             Book book = list.get(i);             if (name.equals(book.getName())){                 System.out.println(book);                 return book;             }         }         return null;     }         /**      * 展示所有图书信息      */     public void showAll(){         for (int i = 0; i < list.size(); i++) {             System.out.println(list.get(i));         }     }       /**      * 按照价格降序排序      */     public void sort(){         Collections.sort(list, new Comparator<Book>() {             @Override             public int compare(Book o1, Book o2) {                 return -(int)(o1.getPrice()-o1.getPrice());             }         });     } }

标签:Book,return,17,int,list,book,public,2022.12
From: https://www.cnblogs.com/GELY0007/p/16989784.html

相关文章