package leiku;
import java.util.Arrays;
class Book12 implements Comparable ///实现比较
{
private String title;
private double price;
public Book12(String title,double price)
{
this.title = title;
this.price = price;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "书名"+this.title+"价格"+this.price+"n";
}
@Override
public int compareTo(Book12 o) { //Arrays。sort() 会自动跳动此方法比较
// TODO Auto-generated method stub
if(this.price>o.price)
{
return -1;
}
else if(this.price
}
public class bijiaoqi {
public static void main(String[] args) {
// TODO Auto-generated method stub
// int data[] = new int [] {1,4,5,7,8,9,2,3,10,6};
// System.out.println(Arrays.binarySearch(data, 9));
// Arrays.sort(data);
// System.out.println(Arrays.binarySearch(data, 9));
// int dataA[] = new int[] {1,2,3};
// int dataB[] = new int[] {2,1,3};
// System.out.println(Arrays.equals(dataA, dataB)); // false
// int data[] = new int [10];
// Arrays.fill(data, 3);
// System.out.println(Arrays.toString(data));
Book12 books[] = new Book12[]
{
new Book12(“asda”,123),
new Book12(“asdsdfa”,133),
new Book12(“assfdsfda”,1223),
new Book12(“asafasdfda”,13223)
};
Arrays.sort(books); ///对象数组排序
System.out.println(Arrays.toString(books));
}
}



