Logical Operator

Logical Operator:
Java language এ কয়েক ধরনের লজিকাল অপারেটর আছে ।  এগুলো সাধারনত শর্ত সত্য বা মিথ্যা অর্থাৎ Boolean  কন্ডিশান চেক করে। জাভাতে মোট তিন ধরনের লজিকাল অপারেটর রয়েছে ।
And——-symbol is         &&
OR  ——-Symbol is        ||
Not  ——-Symbol is        !

And  অপারেটর হল এমন ধরনের যেখানে উভয় কন্ডিশান সত্য হলে তবে ফলাফল সত্য বলে বিবেচিত হয়, একটি বা উভয়টি মিথ্যা হলে ফলাফল মিথ্যা বিবেচিত হয়।

OR  অপারেটর হল এমন যেখানে যে কোন একটি সত্য বা উভয়টা সত্য হলে ফলাফল মিথ্যা বলে বিবেচিত হয়, শুধুমাত্র উভয়টি মিথ্যা হলেই কেবল ফলাফল মিথ্যা হয়।

Not    হল এমন অপারেটর যেখানে শুধু সত্য নাকি মিথ্যা তা বিবেচনা করা হয়।         যেমন  বৃস্টি না এলে আমি ভার্সিটি যাব। এখানে বৃষ্টি হয়ার সম্ভাবনা মিথ্যা হলে   কাজ টি সত্য হবে অর্থাৎ  ভার্সিটি যাব।

একটি উদাহরন  দেখি-

public class logical_oparetor {

public static void main(String arg[]){

int a=5,b=10;

if(a==5&&b==10){
System.out.println(“yes , this is right for and oprerator where both are true  !!”);

}

if(a==5&&b==5){

System.out.println(“yes , this is right for and operator where single one is true !!”);

}

if(a==4&&b==4){

System.out.println(“yes , this is right for and operator where both are false!!”);
}

if(a==5||b==10){

System.out.println(“yes , this is right for or operator where both are true !!”);
}

if(a==5|| b==5){

System.out.println(“yes , this is right for or operator where  single one is true!!”);

}

if(a==4||b==3){
System.out.println(“yes , this is right  for or operator where both are false!!”);

}

if(a!=5){

System.out.println(“yes , this is right for not operator where value is false !!”);

}

if(a!=4){

System.out.println(“yes , this is right where value is true !!”);

}

}
}

Output:
yes , this is right for and oprerator where both are true  !!
yes , this is right for or operator where both are true !!
yes , this is right for or operator where  single one is true!!
yes , this is right where value is true !!