Skip to content

Instantly share code, notes, and snippets.

@dorsev
Last active September 1, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorsev/2101f40a5fd29fa284598242db737a56 to your computer and use it in GitHub Desktop.
Save dorsev/2101f40a5fd29fa284598242db737a56 to your computer and use it in GitHub Desktop.
Person class with toJson method
public class Person {
public String toJson() {
return "{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", nicknames=" + Arrays.toString(nicknames) +
'}';
}
public Person(String firstName, String lastName, String[] nicknames) {
this.firstName = firstName;
this.lastName = lastName;
this.nicknames = nicknames;
}
private String firstName;
private String lastName;
private String[] nicknames;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment