在 Java 中,我们可以做这样的事情:
String output = "";
stop: {
// count 10 lines
for ( int row = 1; row <= 10; row++ ){
// count 5 columns
for ( int column = 1; column <= 5; column++ {
if ( row == 5 )
break stop;
output += "* ";
}
output += "\n";
}
output += "\nTerminated Ok.";
}
结果是打印了 10 行,但它以 5 结尾:
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
有德尔福等价物吗?