有关小城镇建设网站,企业简介宣传片视频,东莞网页平面设计,wordpress 自适应插件创建Employee类#xff0c;在类中定义三个属性#xff1a;编号#xff0c;姓名#xff0c;年龄#xff0c;然后在构造方法里初始化这三个属性#xff0c;最后在实现接口中的定义的CompareTo方法#xff0c;将对象按编号升序排列。代码如下#xff1a;(程序可能有些错误…创建Employee类在类中定义三个属性编号姓名年龄然后在构造方法里初始化这三个属性最后在实现接口中的定义的CompareTo方法将对象按编号升序排列。代码如下(程序可能有些错误方法是对的见谅)import java.awt.List;import java.util.ArrayList;import java.util,Collection;import java.util,Collections;import java.util,Iterator;import java.util,Scanner;class Employee implements omparable{private int id;private String name;private int age;public int getId(){return id;}public void setId(int id){this.idid;}public String getName(){return name;}public void setName(String name){this.name-name;}public int getAge(){return age;}public void setId(int age){this.ageage;}Employee(int id,String name,int age){this.idid;this.namename;this.ageage;}public int compareTo(Object e){Employee o(Employee)e;if(this.ido.id)return 1;else if(this.id}}public class Main{public static void main(String[] args){Scanner innew Scanner(System.in);ArrayList listnew ArrayList();for(int i0;i3;i){int idin,nextInt();String strin.next();int agein.nextInt();list.add(new Employee(id,str,age));}Collections.sort(list);System.out.print([);Iterator itlist.iterator();while(it.hasNext()){Employee e(Employee) it.next();System.out.print(Id e.getIdName e.getName()Age e.getAge());if(it.hasNext())System.out.print(“)System.out.println(]);}}