class Foo{ Bar i = new Bar(); foo(){ if(i == null){} } } class Bar {}