I don't know how to ask right question so here's code:
public class Foo
{
private isTrue;
public Foo() {}
public Foo setBoolean(boolean b)
{
this.isTrue = b;
return this;
}
}
And then:
Foo foo = new Foo().setBoolean(true);
OR
public class FooTwo
{
private isTrue;
public FooTwo() {}
public void setBoolean(boolean b)
{
this.isTrue = b;
}
}
And then:
FooTwo fooTwo = new FooTwo();
fooTwo.setBoolean(true);
Which one is better/faster/preferred (more used)? Why?
Faster in this particular case - declare and call void or return alredy set Foo.