Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Sunday, May 28, 2017

break control statement

break control statement


break statement is used to control the transfer out the block without executing the statements written after break statement . It is used either with switch or looping statement.

Syntax of break statement :
break ;  or   break  < label > ;

< label > : It is used with looping statement and with break it indicates which loop execution will be terminated in the current nesting block.

Some of the Invalid statement of the break statement gives compilation error as " unreachable statement "

for ( int i = 0 ; i < = 10 ; i ++ ) {
System.out.println ( " Before break ") ;
break ;
System.out.println (" After break " );   // Compilation error " unreachable statement "
}

while(true) {
break;
System.out.println("After break") ;   // Compilation error " unreachable statement "
}

In the above code compiler is very sure that statement written after break statement will never execute and hence give compilation error as " unreachable statement ".

Above code with some modification which doesnt give any compilation error.

for ( int i = 0 ; i < = 10 ; i ++ ) {
if ( i == 1 )
break ;
System.out.println (" After break " );   
}

In the above code if statement is used and break is used with it, which indicates that there may be chance of executing statements written after break , when if condition will be false. 

while(true) {
int  i = 10 ;
if ( i == 1 )
break;
System.out.println("After break") ;  
i-- ;
}

Above code will not give any error but execute infinitely because " i " is a local variable and it always allocate memory when loop execute. So its value never fall down from 10 .

Use of break with label 

Label can be used with any looping statement i.e for and while loop.for ex-

ab:                                                       // Here ab is a label for " for " loop.
for ( int i = 0 ; i < = 10 ; i ++ ) { }

ab1 :
for ( int i = 0 ; i < = 10 ; i ++ ) { 
ab2 :
for ( int j = 0 ; j < = 10 ; j ++ ) { 
ab3 :
for ( int k = 0 ; k < = 10 ; k ++ ) { 
break ;                                          // Terminate the current block.
break ab3 ;                                  //  Terminate the k block.
break ab2 ;                                 //  Terminate the j block.
break ab1 ;                                //  Terminate the i block.
}

Note: Let suppose we have multiple array with some value and we want to find some value i.e 34 is available or not  then we need to go for nested loop.  If we found 34 in any one array then no need to execute loop further so we can use break with label statement to transfer the control out of all the loop. 

Available link for download

Read more »

Tuesday, April 25, 2017

Bladder Control

Bladder Control



People may experience urinary incontinence especially as they grow older. Incontinence can be caused when muscles used to control the bladder weaken due to childbirth or prostate surgery.  Neurological complications caused by injury or stroke, or neurologic diseases (like multiple sclerosis) can also weaken bladder control. So can diabetes. 

But the most common cause of urinary incontinence in the older population is what doctors call urge incontinence or bladder instability: Frequent, involuntary bladder contractions release small amounts of urine.

If urinary incontinence is a problem for you, see a urologist, a doctor who specializes in problems and diseases of the urinary system.


To help manage urinary incontinence:
  • Empty your bladder at least every 2 hours.
  • Avoid highly spiced foods, which irritate the bladder.
  • Avoid caffeine and alcohol at least 4 hours before bedtime.
  • Practice Kegel exercises to improve bladder control: Squeeze the pelvic muscles for 3 seconds, then relax them for 3 seconds. Do this 10 times, three times a day.


Used with permission from A Year of Health Hints by Don R Powell, PHD and the American Institute for Preventive Medicine, copyright 2010. www.healthylife.com


Blog Archive