Sorry for barging in here, but whilst reproducing this in Eclipse, I get a compiler error from:
In my opinion, quite rightly so, where is this m1 variable being declared and then called from, on m3??
To give the benefit of the doubt for a possible typo, on the instance variable for the Mixer class did you intend to write:
instead of
if you did then, it compiles: Plese use the preview function to check mistakes before posting or use edit to correct once posted (like i did
)
Looking at the code, and running it I get the nullPointerException where m5.go() is called. m5 is pointing to m2.m1. However m2 was created with a no-arg constructor and then used to construct m3. So providing my assumption about m being m1 was correct, there is no instance of m2.m1 to call go on, and hence the nullPointerReference.
?