1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.

Slides:



Advertisements
Similar presentations
1 Chapter 3:Operators and Expressions| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2006 | Last Updated: July 2006 Slide 1 Operators and Expressions.
Advertisements

Types and Arithmetic Operators
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
JavaScript, Fourth Edition
JavaScript, Third Edition
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Objectives You should be able to describe: Data Types
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
15-Nov-15 All the Operators. operators.ppt 2 Precedence An operator with higher precedence is done earlier (precedes) one with lower precedence A higher.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Operators & Expressions
Doing math In java.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
1 MATERI PENDUKUNG TIPE DATA Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Operators.
Expressions and Order of Operations Operators – There are the standard operators: add, subtract, divide, multiply – Note that * means multiply? (No times.
Programming Principles Operators and Expressions.
ICS102 Lecture 1 : Expressions and Assignment King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
A Sample Program #include using namespace std; int main(void) { cout
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
University of Central Florida COP 3330 Object Oriented Programming
Building Java Programs
ITEC113 Algorithms and Programming Techniques
University of Central Florida COP 3330 Object Oriented Programming
Assignment statement:
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Multiple variables can be created in one declaration
Assignment and Arithmetic expressions
Operators and Expressions
Operators and Expressions
Building Java Programs Chapter 2
All the Operators 22-Nov-18.
Building Java Programs
All the Operators 4-Dec-18.
Building Java Programs
Building Java Programs Chapter 2
Expressions and Assignment
Chapter 2: Java Fundamentals
Chapter 3 Operators and Expressions
All the Operators 6-Apr-19.
Building Java Programs
The Data Element.
All the Operators 13-Apr-19.
Building Java Programs Chapter 2
The Data Element.
Presentation transcript:

1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0

2 Operators Operators allow you to access, manipulate, relate, or refer to Java language elements, from variables to classes. Operators have properties of precedence and associativity. When several operators act on the same element (or operand), the operators' precedence determines which operator will act first. When more than one operator has the same precedence, the rules of associativity apply. These rules are generally mathematical; for instance, operators will usually be used from left to right, and operator expressions inside parentheses will be evaluated before operator expressions outside parentheses. Operators generally fall into six categories: assignment, arithmetic, logical, comparison, bitwise, and ternary. Assignment means storing the value to the right of the = inside the variable to the left of it. You can either assign a value to a variable when you declare it or after you have declared it. The machine doesn't care; you decide which way makes sense in your program and your practice: double bankBalance; //Declaration bankBalance = ; //Assignment double bankBalance = ; //Declaration with assignment

3 In both cases, the value of is stored inside the memory reserved by the declaration of the bankBalance variable. Assignment operators allow you to assign values to variables. They also allow you to perform an operation on an expression and then assign the new value to the right-hand operand, using a single combined expression. Arithmetic operators perform mathematical calculations on both integer and floating-point values. The usual mathematical signs apply: + adds, - subtracts, * multiplies, and / divides two numbers. Logical, or Boolean, operators allow the programmer to group boolean expressions in a useful way, telling the program exactly how to determine a specific condition. Comparison operators evaluate single expressions against other parts of the code. More complex comparisons (like string comparisons) are done programmatically. Bitwise operators act on the individual 0s and 1s of binary digits. Java's bitwise operators can preserve the sign of the original number; not all languages do. The ternary operator, ?:, provides a shorthand way of writing a very simple if-then-else statement. The first expression is evaluated; if it's true, the second expression is evaluated; if the second expression is false, the third expression is used.