Java 中的字串邏輯運算子


讓我們在 Java 中實現字串上的邏輯運算子 -

示例

線上演示

import java.io.*;
public class Demo{
   public static void main(String[] args){
      int a = 45, b = 32, c = 87, d = 1;
      System.out.println("The first variable is " + a);
      System.out.println("The second variable is = " + b);
      System.out.println("The third variable is = " + c);
      if ((a > b) && (b == c)){
         d = a + b + c;
         System.out.println("The sum is " + d);
      }
      else
         System.out.println("The conditions haven't been fulfilled");
   }
}

產出

The first variable is 45
The second variable is = 32
The third variable is = 87
The conditions haven't been fulfilled

一個名為 Demo 的類包含 main 函式,其中聲明瞭 4 個變數,並使用這些變數實現了各種邏輯運算子,並在控制檯上對其進行宣告。

更新日期:17-Aug-2020

545 次瀏覽

開啟你的職業生涯生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.