14.7
Expression Statements
BLOCKS AND STATEMENTS
identifier as a local variable or as the parameter of an exception handler ( 14.18)
does not hide a statement label with the same name.
A labeled statement is executed by executing the immediately contained
Statement
. If the statement is labeled by an
Identifier
 and the contained
Statement
completes abruptly because of a
break
 with the same
Identifier
, then the labeled
statement completes normally. In all other cases of abrupt completion of the
Statement
, the labeled statement completes abruptly for the same reason.
14.7   Expression Statements
Certain kinds of expressions may be used as statements by following them with
semicolons:
ExpressionStatement:
StatementExpression
 ;
StatementExpression:
Assignment
PreIncrementExpression
PreDecrementExpression
PostIncrementExpression
PostDecrementExpression
MethodInvocation
ClassInstanceCreationExpression
An
expression statement
 is executed by evaluating the expression; if the
expression has a value, the value is discarded. Execution of the expression state 
ment completes normally if and only if evaluation of the expression completes
normally.
Unlike C and C++, the Java language allows only certain forms of expressions
to be used as expression statements. Note that Java does not allow a  cast to
void
  
void
 is not a type in Java so the traditional C trick of writing an expres 
sion statement such as:
(void) ... ;
//
This idiom belongs to C, not to Java!
does not work in Java. On the other hand, Java allows all the most useful kinds of
expressions in expressions statements, and Java does not require a method invoca 
tion used as an expression statement to invoke a
void
 method, so such a trick is
almost never needed. If a trick is needed, either an assignment statement ( 15.25)
or a local variable declaration statement ( 14.3) can be used instead.
272






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved