14.15
The
return
 Statement
BLOCKS AND STATEMENTS
class Graph {
. . .
public Graph loseEdges(int i, int j) {
int n = edges.length;
int[][] newedges = new int[n][];
edgelists: for (int k = 0; k < n; ++k) {
int z;
search: {
if (k == i) {
. . .
} else if (k == j) {
. . .
}
newedges[k] = edges[k];
continue edgelists;
}//search
. . .
}//edgelists
return new Graph(newedges);
}
}
Which to use, if either, is largely a matter of programming style.
14.15   The
return
 Statement
A
return
 statement returns control to the invoker of a method ( 8.4,  15.11) or
constructor ( 8.6,  15.8).
ReturnStatement:
return
Expression
opt
 ;
A
return
 statement with no
Expression
must be contained in the body of a
method that is declared, using the keyword
void
, not to return any value ( 8.4), or
in the body of a constructor ( 8.6). A compile time error occurs if a
return
 state 
ment appears within a static initializer ( 8.5). A
return
 statement with no
Expression
 attempts to transfer control to the invoker of the method or constructor
that contains it. To be precise, a
return
 statement with no
Expression
 always
completes abruptly, the reason being a
return
 with no value.
A
return
 statement with an
Expression
 must be contained in a method decla 
ration that is declared to return a value ( 8.4) or a compile time error occurs. The
Expression
 must denote a variable or value of some type
T
, or a compile time
error occurs. The type
T
 must be assignable ( 5.2) to the declared result type of
the method, or a compile time error occurs.
286






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