让我们在Java中对String实现逻辑运算符-
示例import java.io.*;
public class Demo{
public static void main(String[] args){
int a = 45, b = 32, c = 87, d = 1;
System.out.println("第一个变量是 " + 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("总和是 " + d);
}
else
System.out.println("The conditions haven't been fulfilled");
}
}
输出结果第一个变量是 45
The second variable is = 32
The third variable is = 87
The conditions haven't been fulfilled
名为Demo的类包含主要功能,其中声明了4个变量,并使用这些变量实现了各种逻辑运算符,并在控制台上声明了它们。