1. 程式人生 > 實用技巧 >python+selenium截圖

python+selenium截圖

Java運算子

  • Java運算子

    • 算數運算子:+,-,*,/,%(取餘),++,--

    • 賦值運算子:=

    • 關係運算符:<,>,<=,>=,!=

    • 邏輯運算子:&&、||、!(與、或、非)

      package operator;
      //邏輯運算例項
      public class Demo04 {
      public static void main(String[] args) {
      boolean a = true;
      boolean b = false;
      System.out.println(a&&b);
      System.out.println(a||b);
      System.out.println(!(a&&b));

      }
      }

    • 位運算子:&、|、^、~、>>、<<、>>>(瞭解即可)

      package operator;
      //位運算例子
      public class Demo05 {
      public static void main(String[] args) {
      int a = 0b0000_0010;
      int b = 0b0011_1110;
      /*
      a&b 0000 0010
      a|b 0011 1110
      a^b 0011 1100 異或 相同為0 不同為1
      ~b 1100 0001 取反
      位運算效率極高,在底層直接執行的
      左移<< *2
      右移>> /2
      */
      System.out.println(a&b);
      System.out.println(Integer.toBinaryString(a&b));
      System.out.println(Integer.toBinaryString(a|b));
      System.out.println(Integer.toBinaryString(a^b));
      System.out.println(Integer.toBinaryString(~b));
      System.out.println(2<<3);
      }
      }
    • 條件運算子:?:

      package operator;
      public class Demo07 {
      public static void main(String[] args) {
      //條件運算 三元運算
      int a = 60;
      String sorc = a>60?"成功":"不成功";//條件為true的返回前面,false的返回後面
      System.out.println(sorc);
      }
      }

    • 擴充套件賦值運算子:+=、-=、*=、/=

      package operator;
      public class Demo06 {
      public static void main(String[] args) {
      int a = 10;
      int b = 20;
      a += b;//相當於 a = a + b
      a -= b;//相當於 a = a - b
      System.out.println((short)a);//?不顯示正負
      System.out.println(""+a+b);//在數字面前存在String型別的都轉為兩個數字相連,即前面型別可以轉換後面型別
      System.out.println(+a+b+"");
      }
      }