一,运算符

--1,算数运算符: +-*/ ++ -- %(模)--2,比拟运算符(后果是boolean类型):== != --3,逻辑运算符(后果是boolean类型):+ !(取反) & |--4,三元运算符: 1 ? 2 : 3        --后果是2或者是3,到底是2还是3要看1的后果了,1如果形容的成立,后果是2.1如果形容不成立,后果是3.--5,赋值运算符: = += -= *= /=--6,逻辑运算符 & |     --逻辑&:示意并且关系        1 & 2 :如果最终运算的后果,想要是true,要求1和2,必须都是true    --短路与/双与&&:示意并且关系 -- 高效        1 && 2 :            2的地位可能会产生短路,当1的地位判断完失去false时,后果就曾经注定了是false,此时2能够不参加运算(产生短路).能够提高效率.            --逻辑|:示意或者关系        1 | 2 :如果最终运算的后果,想要是true,要求1和2中,有一个true就行    --短路或/双或||:示意或者关系  -- 高效            1 || 2 :            2的地位可能会产生短路,当1的地位判断完失去true时,后果早都注定了是true,此时2能够不参加运算(产生短路).用来提高效率.            --7,练习:自增自减        package cn.tedu.basic;    //这个类用来测试 自增++   自减--    public class Test1_ZIzeng {        public static void main(String[] args) {            int a = 1;            //符号在后,先应用再变动            System.out.println(a++);//1                        int b = 1;            //符号在前,先变动再应用            System.out.println(++b);//2                        System.out.println(++b+b+a++);//3+3+2=8                        int c = 1;            //符号在后,先应用再变动            System.out.println(c--);//1                        int d = 1;            //符号在前,先变动再应用            System.out.println(--d);//0            System.out.println(--c-c-d--);//-1-(-1)-0=0        }    } //这个类用来测试 三元运算符    public class Test2_MaxValue {        public static void main(String[] args) {            int a = new Scanner(System.in).nextInt();            int b = new Scanner(System.in).nextInt();            // 两个数里的大值:max记录的值可能是a也可能是b,到底是a还是b呢?--要看a>b判断成立不            int max = a > b ? a : b;            System.out.println("a b里的大值是:" + max);            // 三个数里的大值:            int c = new Scanner(System.in).nextInt();                        //res记录着max和c里的大值            int res = max  > c ? max : c ;            System.out.println("a b c里的大值是:"+res);                        //TODO 优化:一步到位    //        int res = a > b ? 2 : 3 ;    //        int res = a > b ? a大 : b大 ;            int res = a > b ? ( a > c ? a : c ) : ( b > c ? b : c ) ;            System.out.println("a b c里的大值是:"+res);        }    }        二,!!!分支构造:if--1,概述    分支构造是绝对于程序构造而言的.程序构造只能一行一行程序的从上往下执行.然而无奈实现先判断再执行的需要.--2,语法    单分支:    if(判断条件){        满足了条件代码    }    多分支:    if(判断条件){        满足了条件代码    }else{        不满足了条件代码    }    嵌套分支:    if(判断条件1){        满足了条件代码1    }else if(判断条件2){        满足了条件代码2    }else if(判断条件3){        满足了条件代码3    }else{        下面的谁都不满足才要执行的代码4         package cn.tedu.ifdemo;        import java.util.Scanner;        //这个类用来测试 if        public class Test4_IF {            public static void main(String[] args) {                //1,接管用户输出的原价                double price = new Scanner(System.in).nextDouble();                        //        double discount = price;//定义变量,记录折后价                                //2,开始计算折后价,并输入                if(price >= 5000) {//满5000打5折        //            price = price * 0.5 ;                                        price *= 0.5 ;//等效于:price=price*0.5;相当于是一种简写模式.                                    }else if(price >= 2000) {//满2000打8折        //            price = price * 0.8 ;                    price *= 0.8 ;                }else if(price >= 1000) {//满1000打9折        //            price = price * 0.9 ;                    price *= 0.9 ;                }                //3,输入        //        System.out.println("原价是:"+price+",折后价是:"+discount);                System.out.println("折后价是:"+price);            }        }        --4,练习:统计学员得分    package cn.tedu.ifdemo;    import java.util.Scanner;    //这个类用来测试 if    public class Test5_If2 {        public static void main(String[] args) {            // 1,接管用户输出的分数            int score = new Scanner(System.in).nextInt();            // 为了加强程序的健壮性.设置下限100和上限0            if (score > 100 || score < 0) {                System.out.println("请您输出无效的分数!");                return;// 完结程序            }            // 2,判断            if (score >= 90) {// 90分以上 优良                System.out.println("优良");            } else if (score >= 80 && score <= 89) {// 80~89 良好                System.out.println("良好");            } else if (score >= 70 && score <= 79) {// 70~79 中等                System.out.println("中等");            } else if (score >= 60 && score <= 69) {// 60~69 及格                System.out.println("及格");            } else if (score < 60) {// 60分以下 不及格                System.out.println("不及格");            }        }    }        三,分支构造:switch--1,概述    也能够实现先判断再执行的需要.--2,语法:    switch(判断条件){        case 0 : syso(0) ;    break;        case 1 : syso(1) ;            case 'x' : syso(2) ;            case "java" : syso(3) ;         default:syso(100) ;        }--3,练习:    package cn.tedu.ifdemo;    //这个类用来测试  switch    public class Test6_Switch {        public static void main(String[] args) {                        int sum  = 2 ;            //1,判断条件:能够转化为int类型的表达式.            //能够是byte short char int类型.jdk7当前,反对String类型.            switch(sum) {                case 1 : System.out.println(1);                //2,自从胜利匹配了case后,会持续向后穿透所有case包含default                case 2 : System.out.println(2);break ;//3,立即完结                case '2' : System.out.println('2');break ;                case 'x' : System.out.println('x');break ;                case 100 : System.out.println(100);break ;                                default :System.out.println(666);            }        }    }

四,循环构造:for

--1,概述    是指在程序中,须要反复执行很屡次的某些性能.--2,语法    for(循环的开始地位;循环的判断条件;循环的更改条件){循环体}--3,练习:    package cn.tedu.fordemo;    //这个类用来测试 for循环    public class Test7_For {        public static void main(String[] args) {            //int i = 0 循环的开始地位            //i <= 10 循环的判断条件            //i++ 循环的更改条件,使i一直自增            //i 就示意每次获取到的数据            for(int i = 0; i <= 10 ; i++ ){//练习:打印0到10                System.out.println(i);//打印以后i的值            }                        //练习:打印10到0            for(int i = 10 ; i >= 0  ; i-- ) {                System.out.println(i);            }                        //TODO 打印8,88,888,8888            //TODO 画流程图!!        }    }