If statement is not always followed by a condition in java

This code will compile and run. Notice the assignment operator(=) in the condition.

boolean a;
boolean b = true;
if(a=b){
   //do anything;
   //this compiles
}

But this won’t compile

int a;
int b = 5;
if(a=b){   
   //notice its still = not ==
   //do anything;
   //this does not compile
}

The reason is because the previous code’s a is of

boolean
type and the latter’s is of
int
type.

if
statement is not necessarily followed by a condition.
a=b
is not a condition. Its an assignment. But it works if the left variable (i.e. a) is of a boolean type.

So its better if we think

if(boolean)
instead of
if(condition)
. Anyway, a condition like a==b or a>b etc will result a boolean result.

Toronto 2013 Blackout shelter places on Google map

About 200,000 or more Torontonians are suffering blackout right now.(December 23, 2013). I am writing this in candle light with a little bit of battery left on my phone and laptop by using tethering the internet of my phone to the laptop.

If you are on the road in this freezing weather and need to find a closest shelter, check this map I created on google map. The list is as per emailed to me by the toronto city’s newsletter. I may not be able to update when the list changes in future, so please after finding the location on the map. Call them to verify.

[Read more…]

Splitify – chrome extension to split a webpage for wide screen

I created this chrome extension that splits the webpage that uses the wide screen more effectively. Extract the zip file and install the extension. [Read more…]

Block access to phpmyadmin from LAN network on Xampp

Xampp on windows is set to allow phpmyadmin from your local network. To disable access from your network, Open httpd-xampp.conf located in xampp-folder\apache\conf\extra\httpd-xampp.conf Somewhere down in the bottom of this configuration file is the LocationMatch node Even though you would think the default Order is set to deny, allow with Deny from all. This configuration by default is set to Allow from 192.168.0.#. Remove this ip range and you are set. [Read more…]

Intro / Tutorial of TTC Toronto Transit Live app