java
package ne;
import java.util.List;
import java.util.stream.Stream;
public class c3 {
public static void main(String[] args) {
for (int i = 1; i <= 15; i++) {
System.out.printf("%03d\t", i);
System.out.println();
for (int ix = 15; ix >= 1; ix -= 2) {
System.out.printf("%03d\t", ix);
}
//计算1+2+3+...+100 = ?
int sum = 0;
for (int iv = 1; iv <= 100; iv++) {
sum = sum + iv;
}
System.out.println("\n1+2+3+...+100=" + sum);
}
System.out.printf("===============================\n");
/*
for (;;) {
System.out.println("aaa");
}
*/
for (int i = 3; i <= 13; i++) {
System.out.printf("%02d ", i);
}
System.out.println();
for (int i = 3; i <= 13; i++) {
if (i % 2 != 0) {
System.out.printf("%02d ", i);
}
}
System.out.println();
for (int i = 1; i < 20; i++) {
if (i % 2 != 0) {
System.out.printf("%d ", i);
}
}
System.out.printf("===============================\n");
for (int i = 1; i < 7; i++) {
System.out.printf("%d ", i);
}
System.out.println();
for (int i = 6; i >= 1; i--) {
System.out.printf("%d ", i);
}
System.out.printf("===============================\n");
int num = 15;
for (int i = 1; i < 15; i += 2) {
//String str = " ".repeat(num--) + "*".repeat(i);
//System.out.println(str);
for (int n = --num; n >= 0; n--) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.printf("===============================\n");
// for in(javascript)
// foreach(方法,不能使用continue和break)
// for of (javascript)
//forin foreachforof循环集合数组
int[] nums = {10, 20, 30};
//toList()java16增加的方法
for (int i : Stream.of(1, 2, 3, 4, 5, 6).toList()) {
System.out.println(i);
}
//List.of()接口方法是java9新增方法
for (int i : List.of(10, 20, 30)) {
System.out.println(i);
}
for (int i : Stream.of(11, 22, 33).toList()) {
System.out.println(i);
}
for (int am : nums) {
System.out.println(am);
break;
}
for (String s : new String[]{"java", "php", "python"}) {
System.out.println(s);
}
for (char c : "javascript".toCharArray()) {
System.out.println(c);
}
System.out.println("--------------------------------");
for (String value : System.getenv().values()) {
System.out.println(value);
}
System.out.printf("===============================\n");
System.out.printf("===============================\n");
System.out.printf("===============================\n");
}
}