当前位置:   article > 正文

day72接口练手代码_一张地图包括n个城市,假设城市间有m条路径(有向图),每条路径的长度已知。给定

一张地图包括n个城市,假设城市间有m条路径(有向图),每条路径的长度已知。给定


今天就是敲这么一个昨天的接口的代码的实际练手,一个代码多敲了几遍,这边不重复贴,只贴一个,只待后查接口的用法时可以看。

package com.atguigu.app;



import java.util.Arrays;


public class EmployeeSortTest {
public static void main (String[] args){
Employee[] staff=new Employee[3];
staff[0]=new Employee ("Harry Hacker",35000);
staff[1]=new Employee("Carl cracker",75000);
staff[2]=new Employee("Tony Tester",38000);
Arrays.sort(staff);
for (Employee e:staff)
System.out.println("name="+e.getName()+",salary+"+e.getSalary());
}


}


class Employee implements Comparable <Employee>{
private double salary;
private String name;
public Employee(String n,double s){
name=n;
salary=s;

}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
public int compareTo(Employee other){
if (salary <other.salary) return -1;
if (salary >other.salary) return 1;
return 0;

}

}
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/711078
推荐阅读
相关标签
  

闽ICP备14008679号