Skip to content

Instantly share code, notes, and snippets.

@stepango stepango/Java.java
Created Mar 25, 2017

Embed
What would you like to do?
JavaVsKotllin
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;
}
}
data class Person(var name: String, var age: Int)
@Xsinh

This comment has been minimized.

Copy link

Xsinh commented Oct 23, 2017

Cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.