I have a basic question regarding the code I'm learning from a book. I am new to Java, so I want to learn about best practice here.
Please note the following: https://www.refheap.com/89409
This is just a fragment of this class. There is a line of code:
Vector2f earth = earthMat.mul(new Vector2f());
I rewrote it as follows, and everything worked just fine:
Vector2f earth = new Vector2f(); earth = earthMat.mul(earth);
Is the first statement a more optimized approach? Being new to Java, I'm just trying to figure out if it really is better than the other. Systematically (at least in my opinion) these two statements are easier to digest right now. I like to specifically make calls against the name of the object.
source share