Created
September 21, 2017 20:30
-
-
Save lipeRomani/16d63c8d3a83787b1149af93ca6b6445 to your computer and use it in GitHub Desktop.
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
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