Skip to main content

Posts

Showing posts from April, 2017

About loop statements

Well this is a very basic thing. This is about loop statements on a few programming language. First one is the language Java . That can't be easier than that. Second, C++ . Absolutely not a copy of Java one Looks extremely same. On the next, python This is a lot different from other languages. Its mostly because of python's special  language syntax, not much different from the logic. And more about python's loop, at the first line, it says for i in range(0, 6): . It seems logically, it should be in range(0, 5) to make it repeat to 5. But in python, range(x, y)  counts from x to y + 1, so keep this in mind. And python, doesn't have do {} while ()  statement. So instead, from this stackoverflow answer , there is a somewhat similar code in python. See the line 10, the while loop is infinite loop and it will run the code print k for the first time of the loop. And then, it checks the statement if k>= 5: and determines whether break the loo

About bitwise and bit shift operands

We are getting to know about Java's basics. Java has the bitwise operators. (which all other advanced programming language do either) There are several operands of them. Bitwise operators & opreator Performs an and calculation between data bits ^ opreator Performs an or calculation between data bits | opreator Performs a xor calculation between data bits ~ operator Inverts all data bits Bitshift operators << operator Shifts the bit pattern to the left >> operator Shifts the bit pattern to the right >>> operator Shifts the zero to the leftmost position These are the opreators. which is never used. Even the Java Documentation says these are "less commonly used". So just make sure you 'heard' of these exists. Check out more about these operators here: Official Java Documentation