{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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/
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 +
Image of page 3

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

View Full Document Right 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
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: ==, != Logical and : && Logic or: || Assignment: =, +=, -=, *=, /=, %= Almost all operators work only with primitives All objects work with “=“, “==“, “!=“ String class supports + and +=
Image of page 5

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

View Full Document Right 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
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;
Image of page 7

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

View Full Document Right Arrow Icon
February 10, 2004 (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 necessary to convert the modifying expression to the type of the target
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern