Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.spec.model;
- /**
- *
- * @author Admin
- */
- public class Person implements Comparable<Person>{
- private String name; //
- private int age;
- public Person(String name, int age) {
- this.name = name;
- this.age = age;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- // compareTo - сравниваем два объекта по имени
- @Override
- public int compareTo(Person o) {
- return getName().compareTo(o.getName());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement