国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > Java > 正文

java筆記學(xué)習(xí)之操作符

2024-07-14 08:40:32
字體:
供稿:網(wǎng)友

0x001 算數(shù)運(yùn)算符

    int num1 = 1, num2 = 2;    System.out.println(num1 + num2); // 3    System.out.println(num1 - num2); // -1    System.out.println(num1 / num2); // 0     System.out.println(num1 * num2); // 2    System.out.println(num1 % num2); //1

0x002 自增自減

    System.out.println(num1++); // 1    System.out.println(num1); // 2    System.out.println(num1--); // 2    System.out.println(num1); // 1    System.out.println(++num1); // 2    System.out.println(--num1); // 1

0x003 關(guān)系操作符

    System.out.println((num1 < num2)); // true    System.out.println((num1 > num2)); // false    System.out.println(num1 == num2); // false    System.out.println(num1 != num2); // true

0x004 邏輯操作符

    boolean boolean1 = false;     boolean boolean2 = true;     System.out.println(boolean1 && boolean2); // false    System.out.println(boolean1 || boolean2); // true    System.out.println(!boolean1); // true

0x005 直接操作符

    int i1 = 0x2f;    int i2 = 0x2F;    int i3 = 0177;    char c1 = 0xffff;    byte b1 = 0x7f;    short s1 = 0x7f;    long l1 = 100L;    long l2 = 100l;    float f1 = 1;    float f2 = 1f;    float f3 = 1F;    double d1 = 1d;    double d2 = 1D;    System.out.println(i1); // 47    System.out.println(i2); //47    System.out.println(i3); // 127    System.out.println(c1); //     System.out.println(b1); // 127    System.out.println(s1); // 127    System.out.println(l1); // 100    System.out.println(l2); // 100    System.out.println(f1); // 1.0    System.out.println(f2); // 1.0    System.out.println(f3); // 1.0    System.out.println(d1); // 1.0    System.out.println(d2); // 1.0

0x006 三元運(yùn)算符

    int a = 0;    boolean isSuccess = false;    a = isSuccess ? 1 : 2;    System.out.println(a);// 2

0x007 字符串+、+=

    String str = "";    str = str + "1";    str += "2";    System.out.println(str);

0x008 類型轉(zhuǎn)化

    int i = 100;    long long1 = (long) i;    System.out.println(long1);// 100    long1 = i;    System.out.println(long1);// 100    long long2 = (long) 200;    System.out.println(long2);// 200    i = (int) long1;    System.out.println(i); // 200        float float1=0.1f;     float float2=0.9f;    System.out.println((int) float1);// 轉(zhuǎn)化int會(huì)被舍去    System.out.println((int) float2);// 轉(zhuǎn)化int會(huì)被舍去


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JAVA教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 科尔| 汶上县| 绥德县| 滁州市| 青神县| 聂拉木县| 香港| 三门峡市| 湾仔区| 简阳市| 孟村| 扎鲁特旗| 永春县| 泰州市| 鄄城县| 屏边| 化隆| 浏阳市| 寿光市| 齐齐哈尔市| 和静县| 济南市| 周至县| 扎鲁特旗| 芦山县| 尼木县| 宁安市| 汉寿县| 舞钢市| 荣昌县| 黑水县| 永定县| 桐乡市| 泗洪县| 庄浪县| 德化县| 全南县| 随州市| 鹤壁市| 宜丰县| 唐河县|