SlideShare a Scribd company logo
1 of 2
An operator is a command that interprets given values or variables and produces a
result. They are used to perform calculations on given data.

Operator What It Does

      •    (+) addition
      •    (-) subtraction
      •    (*) multiplication
      •    (/) division
      •    (%) modulus (returns the remainder of a division)

Each of these is a binary operator; that is, they combine two operands to produce a
result—2 + 3 for example will result in 5. An operand is just the term for a value to
which an operator is applied.

Java's logical operators are split into two subtypes, relational and conditional.


Relational Operators

Conditional symbols and their meanings
    Symbol              Condition
==            is equal to
!=            is not equal to
>             is greater than
<             is less than
>=            is greater than or equal to
<=            is less than or equal to

Relational operators are used primarily in if statements, while loops, and on occasion for
loops.

Conditional Operators


Conditional symbols and their meanings
          Symbol             Condition
&&                    AND
||                    OR
!                     NOT
AND is when you need everything to be true

OR is when you need only one thing to be true

Summary:
   •   Operators serve to bring values and/or variables together and yield new results.
   •   Arithmetic operators are used for basic math calculations, as well as
       incrementing and decrementing numeric variables.
   •   Logical operators evaluate comparisons against AND, OR, and NOT conditions
       to determine whether a series of conditions are true or false.
   •   Remember Java always executes code inside parenthesis first!

Sample:

package conditionaloperator;

       /**
       *
       * @author Paul
       */
       public class ConditionalOperator {
              public static void main( String[] args ) {
              String status = "";
              int grade = 85;
              //get status of the student
              status = (grade >= 60)?"Passed":"Fail";
              //print status
              System.out.println( status );
       }
              }

More Related Content

What's hot (20)

Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
 
05 operators
05   operators05   operators
05 operators
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Lecture03(c expressions & operators)
Lecture03(c expressions & operators)Lecture03(c expressions & operators)
Lecture03(c expressions & operators)
 
Operators
OperatorsOperators
Operators
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Operators in Java
Operators in JavaOperators in Java
Operators in Java
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Type conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programmingType conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programming
 
8 if
8 if8 if
8 if
 
conditional statements and operators
conditional statements and operatorsconditional statements and operators
conditional statements and operators
 
Java 2
Java 2Java 2
Java 2
 
Conditional operators
Conditional operatorsConditional operators
Conditional operators
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
 
Demystifying Eta Expansion
Demystifying Eta ExpansionDemystifying Eta Expansion
Demystifying Eta Expansion
 

Viewers also liked

Viewers also liked (12)

Jayakrishnan K - 1.docx
Jayakrishnan K - 1.docxJayakrishnan K - 1.docx
Jayakrishnan K - 1.docx
 
NOMBRAMIENTOS
NOMBRAMIENTOSNOMBRAMIENTOS
NOMBRAMIENTOS
 
Case Solution for SUN Brewing (B)
Case Solution for SUN Brewing (B)Case Solution for SUN Brewing (B)
Case Solution for SUN Brewing (B)
 
Biro_Gabor_CV_English_OK_1
Biro_Gabor_CV_English_OK_1Biro_Gabor_CV_English_OK_1
Biro_Gabor_CV_English_OK_1
 
MVP Award_Peter Lee
MVP Award_Peter LeeMVP Award_Peter Lee
MVP Award_Peter Lee
 
Adse newsletter – irs 2015
Adse newsletter – irs 2015Adse newsletter – irs 2015
Adse newsletter – irs 2015
 
HAVE A GO NEWS - Varenna Jan2013
HAVE A GO NEWS - Varenna Jan2013HAVE A GO NEWS - Varenna Jan2013
HAVE A GO NEWS - Varenna Jan2013
 
Coração
CoraçãoCoração
Coração
 
Ensayo de la formación de alumnos para el futuro
Ensayo de la formación de alumnos para el futuroEnsayo de la formación de alumnos para el futuro
Ensayo de la formación de alumnos para el futuro
 
SCJP-eCertificate
SCJP-eCertificateSCJP-eCertificate
SCJP-eCertificate
 
AACA.PDF
AACA.PDFAACA.PDF
AACA.PDF
 
2
22
2
 

Similar to Week2 dq4

Java class 1
Java class 1Java class 1
Java class 1Edureka!
 
Java Review
Java ReviewJava Review
Java Reviewpdgeorge
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_reviewEdureka!
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c languageshhanks
 
C operators
C operatorsC operators
C operatorsGPERI
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++ANANT VYAS
 

Similar to Week2 dq4 (20)

Guide to Java.pptx
Guide to Java.pptxGuide to Java.pptx
Guide to Java.pptx
 
Java class 1
Java class 1Java class 1
Java class 1
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Java Review
Java ReviewJava Review
Java Review
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
JAVASCRIPT - LinkedIn
JAVASCRIPT - LinkedInJAVASCRIPT - LinkedIn
JAVASCRIPT - LinkedIn
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c language
 
Operators in java By cheena
Operators in java By cheenaOperators in java By cheena
Operators in java By cheena
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
C++
C++ C++
C++
 
Conditonals.pdf
Conditonals.pdfConditonals.pdf
Conditonals.pdf
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
C operators
C operatorsC operators
C operators
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 

More from amaxwell2012 (9)

Week3 dq4
Week3 dq4Week3 dq4
Week3 dq4
 
Week3 dq1
Week3 dq1Week3 dq1
Week3 dq1
 
Week2 dq3
Week2 dq3Week2 dq3
Week2 dq3
 
Week2 dq2
Week2 dq2Week2 dq2
Week2 dq2
 
Week1 dq5
Week1 dq5Week1 dq5
Week1 dq5
 
Week1 dq3
Week1 dq3Week1 dq3
Week1 dq3
 
Week1 dq2
Week1 dq2Week1 dq2
Week1 dq2
 
Week 4 dq 4
Week 4 dq 4Week 4 dq 4
Week 4 dq 4
 
Week 4 dq 3
Week 4 dq 3Week 4 dq 3
Week 4 dq 3
 

Week2 dq4

  • 1. An operator is a command that interprets given values or variables and produces a result. They are used to perform calculations on given data. Operator What It Does • (+) addition • (-) subtraction • (*) multiplication • (/) division • (%) modulus (returns the remainder of a division) Each of these is a binary operator; that is, they combine two operands to produce a result—2 + 3 for example will result in 5. An operand is just the term for a value to which an operator is applied. Java's logical operators are split into two subtypes, relational and conditional. Relational Operators Conditional symbols and their meanings Symbol Condition == is equal to != is not equal to > is greater than < is less than >= is greater than or equal to <= is less than or equal to Relational operators are used primarily in if statements, while loops, and on occasion for loops. Conditional Operators Conditional symbols and their meanings Symbol Condition && AND || OR ! NOT
  • 2. AND is when you need everything to be true OR is when you need only one thing to be true Summary: • Operators serve to bring values and/or variables together and yield new results. • Arithmetic operators are used for basic math calculations, as well as incrementing and decrementing numeric variables. • Logical operators evaluate comparisons against AND, OR, and NOT conditions to determine whether a series of conditions are true or false. • Remember Java always executes code inside parenthesis first! Sample: package conditionaloperator; /** * * @author Paul */ public class ConditionalOperator { public static void main( String[] args ) { String status = ""; int grade = 85; //get status of the student status = (grade >= 60)?"Passed":"Fail"; //print status System.out.println( status ); } }