This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
File codeLoc = new File(protectionDomain.getCodeSource().getLocation().getFile());
is there a process by which I can break down each of the "dots"? i.e., should I always resolve the leftmost method protectionDomain.getCodeSource(), after I get its return value use it on the following method getLocation(), get its return value and use it on the next method getFile())...etc... ? I've never seen a decent explanation when the dots operators are chained together like this and would just like to confirm.
Dan Bromberg wrote:I've never seen a decent explanation when the dots operators are chained together like this and would just like to confirm.
As with any operator, it is dependent on precedence and the associativity. Since they are all the same operator (chain of dot operators), then only the assoc matters. And in the case of the dot operator, the assoc is left to right.