Skip to content

Instantly share code, notes, and snippets.

@lipeRomani
Created September 21, 2017 20:30
Show Gist options
  • Save lipeRomani/16d63c8d3a83787b1149af93ca6b6445 to your computer and use it in GitHub Desktop.
Save lipeRomani/16d63c8d3a83787b1149af93ca6b6445 to your computer and use it in GitHub Desktop.
class Teste {
private int age;
private String name;
private Teste(String name) {
this.name = name;
}
private Teste(int age) {
this.age = age;
}
public static Teste createWithName(String name) {
return new Teste(name);
}
public static Teste createWithAge(int age) {
return new Teste(age);
}
}
Teste testeWithAge = Teste.createWithAge(10);
// ao invés de
Teste testeWithAge = new Teste(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment