Comma operator and Comma separator: Java

Comma separator (not seperator :P) is one that divides and differentiates. As a separator comma is partial and is used to differentiate between two method arguments, or to separate definitions.


subroutine(var A, var B); // comma used to divide

Comma operator has only one use in Java: in the control expression of a for loop when you want to have multiple statements expressed in control expression of for loop at once. Mind my limited knowledge of english and use the following example to have gist of what i want to say.

for(a=1,b=2; a < b; a++,b++){//i am immortal}

Short-Circuiting in Java

I have been absent from about a month, well who the hell is reading this blog??. I write it for myself and will write it on my will and desire. The birth day was a bad day as it has been from few years, (may be after I was dumped by a girl 7 yrs from now). Well the month has been interesting, I have took a pause in game development just to start it again with a better zeal and skill set. This month I had been busy in java and "algorithm analysis and design course" from the most intelligent Tim Roughgarden and a bit in webtoolkit. This post is about java and also soon you would know why am i back to this blog.
It's 23:58hrs of 23rd of june, and while skimming through a book "Thinking in java" I was finding pen and paper to note down some useful stuff. Having failed to locate a pen and paper at my table and the laziness to stand up and find it somewhere else reminded me of this blog. This is one of topic from the basics of java language, that I found interesting and worthy to write here on this blog.

Short circuiting happens when you are dealing with multiple logical operators at once. In contrast to notorious short circuiting in electrical circuits this one increases the potential and saves time.Sounds Interesting huh!
 Suppose there are three subroutines

A()
B() and
C()


they all return a Boolean value which is either true or false. Now suppose another expression involving the results from above mentioned subroutines

A() && B() && C()


Now being little sloppy here I suggest you to suppose again that A() results True, B() results False and C() results True again. Now my friends that are somewhat into programming must be aware that anything that ANDs with false gives a false. Similar to anything multiplied with zero returns zero. So instead of solving all the three subroutines clever java compilers stop at B() because this smart bot knows that whatever the rest of expression may be, the result will eventually be false. This technique saves time and effort and is also termed as "Short Circuiting".

Tip: 
In any OOP language  object.method(arg);under the hood is actually class.method(object,arg);