finalでないprotectedフィールドの使い道
思いつきメモ。
class Hoge { static interface Expr {} static class Add implements Expr { protected Expr left; protected Expr right; } static class Sub implements Expr { protected Expr left; protected Expr right; } static class Value implements Expr { protected int value; } Add result = new Add() {{ left = new Value() {{ value = 10; }}; right = new Sub() {{ left = new Value() {{ value = 7; }}; right = new Value() {{ value = 3; }}; }}; }}; }
逆に読みにくいかも。