package com.jun.scanner;
import java.util.Scanner;
public class Demo01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("使用next方式接收");
if(scanner.hasNext()){
String str = scanner.next();
System.out.println(str);
}
scanner.close();
}
}
while(true){
//do something
}
do{
//这里先执行一次
}while(ex)
for(int i =1;i<=100;i++ ){
//循环体
}
public static void main(String[] args) {
for (int j = 1; j <= 9; j++) {
for (int i = 1; i <= j; i++) {
System.out.print(j+"*"+i+"="+j*i+"\t");
}
System.out.println();
}
}
循环数组
public static void main(String[] args) {
int [] numbers = {10,20,30,40,50};
for(int i:numbers){
System.out.println(i);
}
}
for (int i = 1; i <= 5; i++) {
for (int j = 5; j >=i; j--) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
for (int j = 1; j < i; j++) {
System.out.print("*");
}
System.out.println();
}
原文:https://www.cnblogs.com/whokillbill/p/java-liu-cheng-kong-zhi.html