Skip to content

Instantly share code, notes, and snippets.

@fermopili
Created March 19, 2017 12:20
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 fermopili/3613a13daa3cf6f10f1e2cbfc98609ed to your computer and use it in GitHub Desktop.
Save fermopili/3613a13daa3cf6f10f1e2cbfc98609ed to your computer and use it in GitHub Desktop.
com.javarush.task.task13.task1306
/*
Баг в 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