आइए जावा में स्ट्रिंग पर लॉजिकल ऑपरेटरों को लागू करें -
उदाहरण
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
डेमो नामक एक वर्ग में मुख्य कार्य होता है, जहां 4 चर घोषित किए जाते हैं, और विभिन्न तार्किक ऑपरेटरों को इन चरों का उपयोग करके कार्यान्वित किया जाता है, और उन्हें कंसोल पर घोषित किया जाता है।