2014-08-13 16:17:21 -04:00
|
|
|
package unit.classes;
|
2014-03-04 09:13:11 -05:00
|
|
|
|
2014-08-13 16:17:21 -04:00
|
|
|
public class TestClassLoop {
|
2014-03-04 09:13:11 -05:00
|
|
|
|
2014-08-13 16:17:21 -04:00
|
|
|
public static void testSimpleInfinite() {
|
2014-03-04 09:13:11 -05:00
|
|
|
|
2014-08-13 16:17:21 -04:00
|
|
|
while(true) {
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void testFinally() {
|
|
|
|
|
|
|
|
boolean a = (Math.random() > 0);
|
|
|
|
|
2014-03-04 09:13:11 -05:00
|
|
|
while(true) {
|
|
|
|
try {
|
|
|
|
if(!a) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
System.out.println("1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-08-13 16:17:21 -04:00
|
|
|
|
|
|
|
public static void testFinallyContinue() {
|
|
|
|
|
|
|
|
boolean a = (Math.random() > 0);
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
try {
|
|
|
|
System.out.println("1");
|
|
|
|
} finally {
|
|
|
|
if(a) {
|
|
|
|
System.out.println("3");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("4");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-03-04 09:13:11 -05:00
|
|
|
|
|
|
|
}
|