Java-ControlFlow-Spr04 - Operations, Decisions and...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Operations, Decisions and Iteration COP 3330 © Rong Wang School of Computer Science Febuary 2004
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
February 10, 2004 (c) Rong Wang 2 References Object Oriented Software Development Using Java by Xiaoping Jia, Addison-Wesley, 2000; ISBN = 0-201-35084-X Thinking in Java Bruce Eckel , Prentice Hall PTR, 2003 ISBN = 0-13-100287-2 Web Sites http://java.sun.com/docs/books/jls/index.html http://java.sun.com/
Background image of page 2
February 10, 2004 (c) Rong Wang 3 Java Operations Operators Precedence Assignments Mathematical operators Auto increment and decrement Bitwise operators Shift operators String operator +
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
February 10, 2004 (c) Rong Wang 4 Decision and Iteration Decisions boolean algebra and truth tables boolean type If and else Switch Iteration Do-while For Break and continue
Background image of page 4
February 10, 2004 (c) Rong Wang 5 Java Operation Operators group operator: ( ) Unary operators: +, -, ! Multiplicative arithmetic: *, /, % Additive arithmetic: +, - Relational ordering <, >, <=, >= Relational equality: ==, != Logic or: || Assignment: =, +=, -=, *=, /=, %= Almost all operators work only with primitives All objects work with “=“, “==“, “!=“ String class supports + and +=
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
February 10, 2004 (c) Rong Wang 6 Precedence Rules to determine operation orders: The grouping operators ( ) have the highest precedence The unary operators – and + have higher precedence than *, / and % The multiplicative operators have higher precedence than addition and subtraction Example: R = A + B * C -D R = (A+B) * (C - D) R = A * -D unary minus group operators
Background image of page 6
February 10, 2004 (c) Rong Wang 7 Assignment Format target = expression Compound assignment target += expression target -= expression target *= expression target /= expression target %= expression Example: int a = a + b; int a += b; // a = a + b;
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(c) Rong Wang 8 Assignment (cont’d) Assignment conversions and casting If the target and modifying expression do not have the same type, it is
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/04/2011 for the course COP 3330 taught by Professor Staff during the Summer '08 term at University of Central Florida.

Page1 / 21

Java-ControlFlow-Spr04 - Operations, Decisions and...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online