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.