java中的容器排序,需要类实现Comparable接口, 同时重写该接口的compareTo( )方法。该接口只有这一种方法,当前面类的某个属性值大于后者,返回正值,等于则返回0,小于则返回负值。
import java.util.*;
class Student implements Comparable
{
String name;
int id;
public Student()
{
}
public Student(String name,int id)
{
this.name=name;
this...
import java.util.Scanner;
class bankcard
{
private String name;
private long num;
private int[] password=new int[6];
private int balance;
public String bankname;
public bankcard()
{
String name="none";
num=0L;
password=new int[]{0,0,0,0,0,0};
balance=0;
banknam...
public class TestJava
{
public static void main(String[] args)
{
System.out.println("Hello JAVA!");
}
}