SHARE
TWEET

Sample Java Android Code

a guest May 18th, 2017 13,315 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Customer {
  2.    private String name;
  3.    private String email;
  4.    private String company;
  5.  
  6.    public Customer(String name) {
  7.        this(name, "", "");
  8.    }
  9.  
  10.    public Customer(String name, String email) {
  11.        this(name, email, "");
  12.  
  13.    }
  14.  
  15.    public Customer(String name, String email, String company) {
  16.        this.name = name;
  17.        this.email = email;
  18.        this.company = company;
  19.    }
  20.  
  21.    public String getName() {
  22.        return name;
  23.    }
  24.  
  25.    public void setName(String name) {
  26.        this.name = name;
  27.    }
  28.  
  29.    public String getEmail() {
  30.        return email;
  31.    }
  32.  
  33.    public void setEmail(String email) {
  34.        this.email = email;
  35.    }
  36.  
  37.    public String getCompany() {
  38.        return company;
  39.    }
  40.  
  41.    public void setCompany(String company) {
  42.        this.company = company;
  43.    }
  44.  
  45.    @Override
  46.    public boolean equals(Object o) {
  47.        if (this == o) return true;
  48.        if (o == null || getClass() != o.getClass()) return false;
  49.  
  50.        Customer customer = (Customer) o;
  51.  
  52.        if (name != null ? !name.equals(customer.name) : customer.name != null) return false;
  53.        if (email != null ? !email.equals(customer.email) : customer.email != null) return false;
  54.        return company != null ? company.equals(customer.company) : customer.company == null;
  55.    }
  56.  
  57.    @Override
  58.    public int hashCode() {
  59.        int result = name != null ? name.hashCode() : 0;
  60.        result = 31 * result + (email != null ? email.hashCode() : 0);
  61.        result = 31 * result + (company != null ? company.hashCode() : 0);
  62.        return result;
  63.    }
  64.  
  65.    @Override
  66.    public String toString() {
  67.        return "Customer{" +
  68.                "name='" + name + '\'' +
  69.                ", email='" + email + '\'' +
  70.                ", company='" + company + '\'' +
  71.                '}';
  72.    }
  73. }
RAW Paste Data
Want to get better at Java?
Learn to code Java in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top