August 6, 2012

Boolean assignment in java

Question by siik

Can you explain this assignment? What does it mean?

boolean activityExists = testIntent.resolveActivity(pm) != null;

Answer by Starx

It means to assign true if testIntent.resolveActivity(pm) does not return null otherwise assigns false.

Understandable long form of this would be

boolean activityExists;
if(testIntent.resolveActivity(pm) != null) {
    activityExists = true;
} else {
    activityExists = false;

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!