Day08

自增、自减、逻辑、位运算符

package operator;

public class Demo01 {
    public static void main(String[] args) {
        //二元运算符
        //ctrl+D:复制当前行到下一行
        int a=10;
        int b=20;
        int c=25;
        int d=25;
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/(double)b);

    }
}
package operator;

public class Demo02 {
    public static void main(String[] args) {
        long a=131651615611L;
        int b=123;
        short c=10;
        byte d=8;
        System.out.println(a+b+c+d);//Long
        System.out.println(b+c+d);//Int
        System.out.println(c+d);//Int

    }
}
package operator;

public class Demo03 {
    public static void main(String[] args) {
        //关系运算符返回结果:正确或错误
        int a=10;
        int b=20;
        int c=21;
        System.out.println(c%a);
        System.out.println(a>b);
        System.out.println(a<b);
        System.out.println(a==b);
        System.out.println(a!=b);
    }
}
package operator;

public class Demo04 {
    public static void main(String[] args) {
        int a=3;
        int b=a++;
        int c=++a;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        //幂运算 2^3 2*2*2=8 很多运算,我们会使用一些工具来操作
        double pow=Math.pow(2,3);
        System.out.println(pow);
    }
}
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页