new Picture()
is instantiating a new picture object, which will call it's constructor. It's .edit();
is a method which it calls right away.
Since edit()
is not static, it needs to be run from an instantiated class.
It's the same as typing
Picture pic = new Picture();
pic.edit();
The only difference is pic
can be reused later without having to instantiate and construct a new Picture
object every time.
Calling it by new Picture().edit();
is good for a short-handed way of doing a one off call on something as garbage collection will take care once it's finished executing.