1.java的基本结构,顺序结构按照顺序一句一句的执行
2.顺序结构是最简单的算法结构
3.他是任何一个算法都离不开的基本算法结构。
if(布尔表达式){
//如果值为true
}
equals
Scanner scanner = new Scanner(System.in);
?
System.out.println("请输入内容:");
String s = scanner.nextLine();
?
//equals 判断字符串是否相等
if(s.equals("Hello")){
    System.out.println("Hello word");
    
}
  scanner.close();
if(){
//true
}else{
//flase
}
public class ifDemo01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
?
        System.out.println("请输入内容:");
        String s = scanner.nextLine();
?
        //equals 判断字符串是否相等
        if(s.equals("Hello")){
            System.out.println("Hello word");
?
        }else{
        System.out.println("黑凤梨i");
        }
        scanner.close();
    }
}
        if(s.equals("Hello")){
            System.out.println("Hello word");
        }else if (){
            //
        }else if (){
            //
        }else if (){
            //
        }else if (){
            //
        } else{
        System.out.println("黑凤梨i");
        }
        scanner.close();
    }
}
swith 匹配一个具体的值
case : (冒号)穿透
    public static void main(String[] args) {
    //case穿透 //switch 匹配一个具体的值
    char gread =‘C‘;
    switch (gread){
        case ‘A‘:
            System.out.println("shsf");
            break;
        case ‘B‘:
            System.out.println("awff");
            break;
        case ‘C‘:
            System.out.println("shssvf");
            break;
            //不在条件内的 其他
        default:
            System.out.println("未知")
    }
 }
}
//反编译 找到Project Structure >> Project >> 找到位置
//把 .class文件 Copy到IDEA 文件内即可运行
while(布尔表达式){
}
只要布尔表达式为true,循环就会一直执行下去。
我们大多情况下是会让循环停下来的,我们需要一个让表达式实效的方法来借宿循环。
正常业务编程应尽量避免死循环。
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    double sum =0;
    int m = 0;
    while(scanner.hasNextDouble()==true){
        double v = scanner.nextDouble();
        m++;
        sum = sum+ v;
    }
    System.out.println("总数和为:"+ sum);
    System.out.println("总ge数为:"+ m);
    scanner.close();
}
public class ifDemo01 {
    public static void main(String[] args) {
        int a = 0;
        //先判断 后执行
        while(a<10){
            System.out.println(a);
            a++;
        }
        System.out.println("_________________________");
        int i = 0;
        int sum = 0;
        //先执行,后判断
        do{
            sum = sum + i;
            i++;
        }while (i <=100);
        System.out.println(sum);
    }
}
for循环可以是一些循环结构变得简单
for循环语句是支持迭代的一种通用结构,是最有效,最灵活的循环结构
快捷for循环: 100.for(IDEA)
    public static void main(String[] args) {
        int oddSum = 0;//奇数
        int evenSum = 0;//偶数
        // 快捷键 20.for
        for (int i = 0; i < 20; i++) {
            if(i%2!=0){
                oddSum+=i;
            }else{
                evenSum+=i;
            }
        }
        System.out.println("奇数和为:"+oddSum);
        System.out.println("偶数和为:"+evenSum);
?
    }
}
public class forDemo04 {
    public static void main(String[] args) {
        //练习2:用while或for循环输出1-1000之间能被5整除的数,并且每行输出3个
        for (int i = 0; i < 1000; i++) {
            if(i%5==0){
                System.out.print(i+"\t");
            }
            //整除的倍数几倍就几个输出
            if(i%15==0){
                System.out.print("\n");
            }
        }
?
?
    }
}
public class forDemo05 {
    public static void main(String[] args) {
        /**分析:
         * 1.先打印出乎第一列,
         * 2.把固定的1 用另一个for循环包起来
         * 3.去掉重复的 i<=j ,用"\t"每输出完一个空
         * 4.调整样式 用System.out.println();每输出完一列换行
         *
         */
        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();
        }
?
    }
}
int[] number = {1,2,3,4,5,}; //定义了一个数组
//遍历数组
//把number这个数组里的元素赋值给int x
for(int x:number){
System.out.println(x);
}
原文:https://www.cnblogs.com/li369/p/14030214.html