标签:bre == junit simple example 死循环 port using http
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
public class ForExample {
@Test
public void test() {
// Simple For Loop
for (int i = 1; i <= 10; i++) {
System.out.println(i);
}
System.out.println("---------------------");
}
@Test
public void test1() {
int arr[] = { 12, 23, 44, 56, 78 };
// Printing array using for-each loop
for (int i : arr) {
System.out.println(i);
}
System.out.println("---------------------");
}
@Test
public void test2() {
List<Integer> list = Arrays.asList(12, 23, 44, 56, 78);
list.stream().forEach((i) -> System.out.println(i));
System.out.println("---------------------");
}
@Test
public void test3() {
for (int i = 1; i <= 3; i++) {
bb: for (int j = 1; j <= 3; j++) {
if (i == 2 && j == 2) {
break bb;
}
System.out.println(i + " " + j);
}
}
System.out.println("---------------------");
}
@Test
public void test4() {
aa: for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
if (i == 2 && j == 2) {
break aa;
}
System.out.println(i + " " + j);
}
}
}
@Test
public void test5() {
// 死循环
for (;;) {
System.out.println("infinitive loop");
}
}
}
标签:bre == junit simple example 死循环 port using http
原文地址:https://www.cnblogs.com/hglibin/p/9512309.html