Wednesday, September 30, 2015

Logic in Java

log·ic
ˈläjik/
noun
noun: logic
  1. 1.
    reasoning conducted or assessed according to strict principles of validity.

    "experience is a better guide to this than deductive logic"

    synonyms:reasoning, line of reasoning, rationale, argument, argumentation

    "the logic of their argument"
    • a particular system or codification of the principles of proof and inference.

      "Aristotelian logic"
    • the systematic use of symbolic and mathematical techniques to determine the forms of valid deductive argument.
      plural noun: logics
    • the quality of being justifiable by reason.

      "there's no logic in telling her not to hit people when that's what you're doing"

      synonyms:reason, judgment, logical thought, rationality, wisdom, sense, good sense, common sense, sanity;
      informalhorse sense

      "this case appears to defy all logic"
    • the course of action or line of reasoning suggested or made necessary by.

      "if the logic of capital is allowed to determine events"
  2. 2.
    a system or set of principles underlying the arrangements of elements in a computer or electronic device so as to perform a specified task.


Logic. Something that is occasionally lost to the entire world, or so it would seem.

when programming in Java sometimes we need to compare two values, this brings logic into the equation. We have to deal with logical and's, or's, not's and exclusive or's; these might sound a little complicated but with a nice cheat sheet reference guide you too can master the art of logic in programming. You will find yourself using this logic a lot in programming.

Logical && (AND)

True && True = TRUE
True && False = FALSE
False && True = FALSE
False && False = FALSE

Logical || (OR)

True || True = TRUE
True || False = TRUE
False || True = TRUE
False and False = FALSE

Logical ! (NOT)

! True = FALSE
! False = TRUE

Exclusive ^ (OR)

True ^ True = FALSE
True ^ False = TRUE
False ^ True = TRUE
False ^ False = FALSE








No comments:

Post a Comment