break, return, and Empty Statements

 

Python

Java

 

The break statement exits a loop.

 

while True:

    break

 

The return statement exits a function or method.  If no expression is specified, the value None is returned.

 

return 0

 

The pass statement does nothing.   

 

while True:

    pass

 

 

 

The break statement exits a loop.

 

while (true)

    break;

 

The return statement exits a method.  If no expression is specified, the value void is returned.  The value returned must be type compatible with the methodŐs return type.

 

return 0;

 

The empty statement is an extra semicolon and does nothing.   

 

while (true)

    ;

 

 

Previous

Index

Next