Created
March 19, 2017 12:20
-
-
Save fermopili/3613a13daa3cf6f10f1e2cbfc98609ed to your computer and use it in GitHub Desktop.
com.javarush.task.task13.task1306
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
/* | |
Баг в initializeIdAndName | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
System.out.println(Matrix.NEO); | |
System.out.println(Matrix.TRINITY); | |
} | |
static class Matrix | |
{ | |
public static DBObject NEO = new User().initializeIdAndName(1, "Neo"); | |
public static DBObject TRINITY = new User().initializeIdAndName(2, "Trinity"); | |
} | |
interface DBObject | |
{ | |
DBObject initializeIdAndName(long id, String name); | |
} | |
static class User implements DBObject | |
{ | |
long id; | |
String name; | |
public User initializeIdAndName(long id, String name) | |
{ | |
this.id = id; | |
this.name = name; | |
return this; | |
} | |
@Override | |
public String toString() | |
{ | |
return String.format("User has name %s, id = %d", name, id); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment