I haven't looked through why doFoo() doesn't work yet but I'll get to that.
is a matter of scope. http://www.java-made-easy.com/variable-scope.html
Basically, in class Bar there are two variables named "foo" - the one in the parameter of the constructor ("public bar(Foo foo)") and the class field - "private Foo foo"
The code sets the class field foo to the parameter foo, because otherwise you would just be setting foo equal to itself (parameter foo takes priority over class field foo).
tl;dr this.foo refers to class fields, and foo refers to local variables when applicable.