Created
March 25, 2017 03:25
-
-
Save stepango/90345ba6af99826b5f2916da90f85007 to your computer and use it in GitHub Desktop.
JavaVsKotllin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Person { | |
private String name; | |
private int age; | |
public Person(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
public Person(String name) { | |
this.name = name; | |
this.age = age = 18; | |
} | |
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; } | |
public float getHeight() { return height; } | |
public void setHeight(float height) { this.height = height; } | |
@Override | |
public String toString() { | |
return "Person{" + | |
"name='" + name + '\'' + | |
", age=" + age + | |
'}'; | |
} | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
Person person = (Person) o; | |
if (age != person.age) return false; | |
return name != null ? name.equals(person.name) : person.name == null | |
} | |
@Override | |
public int hashCode() { | |
int result = name != null ? name.hashCode() : 0; | |
result = 31 * result + age; | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Person(var name: String, var age: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool