Last active
June 21, 2017 06:48
-
-
Save NSLog0/751e6197133f0ae3454bf951d2f9726e to your computer and use it in GitHub Desktop.
data class
This file contains hidden or 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 class Person { | |
| private String firstName; | |
| private String lastName; | |
| private String age; | |
| public Person(String firstName, String lastName, String age){ | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| this.age = age; | |
| } | |
| public String getFirstName() { | |
| return firstName; | |
| } | |
| public void setFirstName(String firstName) { | |
| this.firstName = firstName; | |
| } | |
| public String getLastName() { | |
| return lastName; | |
| } | |
| public void setLastName(String lastName) { | |
| this.lastName = lastName; | |
| } | |
| public String getAge() { | |
| return age; | |
| } | |
| public void setAge(String age) { | |
| this.age = age; | |
| } | |
| @Override public String toString() { | |
| return "Person(firstName="+ firstName + ", lastName="+ lastName + ", age="+ age + ")"; | |
| } | |
| } |
This file contains hidden or 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 firstName: String, var lastName: String, var age: String) { | |
| override fun toString(): String { | |
| return "Person(firstName=$firstName, lastName=$lastName, age=$age)"; | |
| } | |
| } |
This file contains hidden or 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
| val person1: Person = Person("John", "Doe", "30") | |
| val person2: Person = Person("Siri", "Doe", "34") |
This file contains hidden or 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 firstName: String? = null, var lastName: String? = null, var age: String = "30") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment