The code has been adapted from OCA/OCP test prep java 8
When I had invoked the playMusic() method, it just printed Music!, then when I use println method, then Music!2 was printed. my question is : when I invoked the playMusic() method, why didn't it print Music!2 ?
Because you didn't tell the main() method to print the result of the first time you call the playMusic() method. It returned 2, but you just ignored the return value. The second time you call playMusic(), you do it inside a println() call.