Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Logical Operators on String in Java
Let us implement logical operators on String in Java −
Example
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");
}
}
Output
The first variable is 45 The second variable is = 32 The third variable is = 87 The conditions haven't been fulfilled
A class named Demo contains the main function, where 4 variables are declared, and various logical operators are implemented using these variables, and they are declared on the console.
Advertisements