Wednesday, May 14, 2014

ජාවා operators (3න් වන කොටස)


Boolean  Logical  Operators
පිමේපාමෙන්‍ ‍ගන්‍‍යන්‍‍නෙ ‍boolean  Logical  Operators ‍ගැ. ‍යාපිලින්‍ ‍පාමෙන්‍ ‍ගෙනාපු operators  ගැහොදැනීමක්‍ ‍තැයි ‍‍පිසි. ‍තින්‍ ‍මෙ  ‍boolean  Logical  operators  පිබාවිතාරන්‍‍නෙතාර්කිවශ්තාටුගන්‍‍. ‍පිමු operators  ගැ. ‍(යාදන්‍‍තිනේ gates  ගැ. ‍අන්‍‍ගැපොඩ්‍‍ඩක්‍ ‍තක්‍ ‍ගන්‍‍).

Operator
Name
  &
Logical  AND
  |
Logical OR
  ^
Logical XOR
  &&
Short Circuit AND
  ||
Short Circuit  OR
  !
Logical NOT
  &=
AND Assignment
  |=
OR  Assignment
  ^=
XOR Assignment

AND  Operator  (  &&  )
මෙ operator  කේහැසිරී  chart  ගින්‍ ‍පැදිලිවෙයි.
        A
         B
      A && B
False
False
False
False
True
False
True
False
False
True
True
True
Logic  AND  GATES ‍හිහැසිරී ‍‍තක්‍ ‍ගන්‍‍යුරින්‍ ‍මෙහි ක්රියාසිදුවෙයි, ‍එ‍නම්‍ A,B  ‍අ‍වස්‍‍තා 2‍ක‍ම true  ‍ව‍න ‍වි‍ට ‍ප‍ම‍නක්‍ ප්‍ර‍ති‍ප‍ල‍ය true  ‍ව‍නු ‍ඇ‍ත


OR Operator  (  ||  )
මෙ operator  කේහැසිරී  chart  ගින්‍ ‍පැදිලිවෙයි


        A
         B
      A || B
False
False
False
False
True
True
True
False
True
True
True
True
Logic  OR  GATES  හිහැසිරී ‍‍තක්‍ ‍ගන්‍‍යුරින්‍ ‍මෙහි ක්රියාසිදුවෙයි, ‍එ‍නම්‍ A,B  ‍අ‍වස්‍‍තා 2‍ න්‍ ‍එ‍කක්‍ ‍හෝ ‍අ‍වස්‍‍තා 2‍ම ‍හෝ  true ‍ව‍න ‍වි‍ට ප්‍ර‍ති‍ප‍ල‍ය ‍ද true  ‍වේ . ‍එ‍නම්‍ ‍ස‍ර‍ල ‍ව‍ශ‍යෙන්‍ ප්‍ර‍ති‍ප‍ල‍ය true  ‍වී‍ම‍ට A  ‍හෝ B  ‍අ‍වස්‍‍තා ‍ව‍ලින්‍ ‍එ‍කක්‍ ‍ප‍ම‍නක්‍ true ‍වී‍ම ප්‍ර‍මා‍න‍වත්‍ය.


XOR Operator  (  ^  )
මෙ operator  කේහැසිරී  chart  ගින්‍ ‍පැදිලිවෙයි
        A
         B
      A ^ B
False
False
False
False
True
True
True
False
True
True
True
False
Logic  XOR  GATES  හිහැසිරී ‍‍තක්‍ ‍ගන්‍‍යුරින්‍ ‍මෙහි ක්රියාසිදුවෙයි, ‍මෙ‍ම operatore  ‍එ‍කේ‍දී  A ‍හෝ B  ‍අ‍වස්‍‍තා 2න්‍ ‍එ‍කක්‍ ‍ප‍ම‍නක්‍ true  ‍ව‍න‍වි‍ට ප්‍ර‍ති‍ප‍ල‍ය  true    ව‍නු ‍ඇ‍ත


NOT  Operator  (  !  )
             A
          !A
True
False
False
True
Logic  NOT  GATES  හිහැසිරී ‍‍තක්‍ ‍ගන්‍‍යුරින්‍ ‍මෙහි ක්රියාසිදුවෙයි.


‍**යාදැන්‍ ‍ති  &   =  Logical  And ‍ලෙදුන්‍‍ &&=   short  circuit  AND ‍ලෙසත්‍ ‍දුන්‍‍‍ ‍ගුදි Logical   AND ‍ලෙකෙලින්‍‍යි && ‍යෙදුවෙකි. ‍හේතුයිමේපැහැදිලිරන්‍‍යන්‍‍නෙ. ‍මෙතාවැගත්‍.
Logical   AND ‍නම්‍ & operator  බාවියේදී ප්තිබාදී  operatore ‍දෙති  Conditions ‍කානු. ‍හෙත්‍ Short   circuite   AND ‍කේදීවම්‍ ‍ති Condition  False  නම්ප්ති False  ලෙබාදෙනු. ‍‍නම්‍ ‍කුනු condition  රීක්‍‍ශාකිරීසිදුනොයි . java   programming ‍දීඩා ‍‍හුබාවිතානුයේ   Short   circuite  Operators ‍. ‍මන්‍‍යත්‍ ‍හිකාර්යක්‍‍තා ‍ ‍වේ.
‍ප‍හ‍ත code  ‍එ‍ක ‍ Run කබ‍ලන්‍‍න

public class booleanOperator {
  public static void main(String args[]) {
    boolean a=true;
    boolean b=false;
   
    System.out.println("value of a : "+(a));
    System.out.println("value of b : "+(b));
    System.out.println("a&b        : "+(a&b));
    System.out.println("a|b        : "+(a|b));
    System.out.println("a^b        : "+(a^b));
    System.out.println("a&&b       : "+(a&&b));
    System.out.println("a||b       : "+(a||b));
  }
}

මෙහි  out  put ‍දැක්‍‍වේ. ‍හි boolean   Logical  operator ‍ගැදැනුමක්‍ ‍බාගන්‍‍තිකි. ‍ගැලුතිනම්‍ ‍පෙන්‍ ‍හන්‍‍. ‍පිමී post  කෙන්‍ ‍නැමුවෙමු. ‍‍කාරි coding  ලිපු java   files ‍නම්‍ ‍පිකියන්‍‍පි Download  රන්‍‍පුලුවන්‍ ‍විදි Link  මන්‍‍නම්‍. ‍පිත්‍ ‍එක්‍‍දිඉන්‍‍. ‍ලාදැනුබිදක්‍ ‍හෝබාදීපේහින්‍‍තුයි


By Manoj Priyankara


2 comments:

  1. "NOT" Operator eka gana therunnah :(

    ReplyDelete
  2. gates matakada.note gate eka eke vidiyatai mee dee sidu venne ee kiyanne api labaa dena input ekata out put denne input ekee prathivirudda dee.ok. api hithamu 1 input nan out put 0 man e kivve digital signal eken.api meeeke use karee boolean agayan.true haa false. itin true ekee not eka false,false eke not eka true.
    terunada
    a=true nam !a=false
    a=false nam !a=true

    ReplyDelete