this bit of code produces no output, somebody please explain me why, public class inter1{ public static void main(String argv[]){ inter1 mi = new inter1(); } inter1(){ boolean b=true; if(b=false){ System.out.println("The value of b is"+b); } } }
When you say if(b=false), you are assigning false to b, thus the condition is not met and no output. To get output, either do if(b) or if(b=true). You are assigning true to b once again in the second case. Hope it helps.
Try this public class inter1{ public static void main(String argv[]){ inter1 mi = new inter1(); } inter1(){ boolean b=true; if(b!=false){ // Changed Here System.out.println("The value of b is"+b); } } }