4.1 Object Operations
4.1.1 operators
•   Dot ( . ) and new operate on objects
•   The assignment operator ( = )
•   Arithmetic operators + - * ...
4.2.6 Boolean data and comparison
            operators
• boolean values are true or false ( not 1 or 0)
• Less than <, gr...
4.2.8 Conditional operator
• Alternative for if - else

y = x > 4 ? 99: 9;
Is the same as:
if(x > 4)
    y = 99;
else
    ...
4.2.9 Bitwise operators
• Perform shifting of bits on integral types,
  preferably int of long
• <<3 shifts all bits left ...
4.3.1 Casting and conversion
• Casting assigns a value of one type to a
   variable of another type
• If it is possible to...
4.4.2 String and StringBuffer class
• The String object can be used to store an
  arbitrary number of textual characters
•...
4.5.1 Decision making and
              repetition
• Control structures control the flow of statement
  execution
• Three ...
4.5.3 If statement
• Basic
if(x == 3) {
   System.out.println(“x equals 3”);
   }
else {
   System.out.println(“x does not...
4.5.4 Multiple condition If
• Multiple condition
if(a < b) {
   System.out.println(“a is less than b”);
}
else if (a < c) ...
4.5.5 Nested if
• Nested If
if(x == 3) {
   System.out.println(“x equals 3”);
   if( y == 4) {
      System.out.println(“ ...
4.5.6 Switch statements
•     A conditional control structure that allows a value to be compared to
      more than one ot...
4.5.7 Loop
• do while: Execution loops. Conditional
  evaluation at the end of the loop
• while: Execution loops through t...
4.5.11 Use of break, continue, and
               label
• break is used to exit a block
• continue is used to return to th...
4.6.1 The java.lang.System class
Upcoming SlideShare
Loading in...5
×

Chapter4

307
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
307
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chapter4

  1. 1. 4.1 Object Operations
  2. 2. 4.1.1 operators • Dot ( . ) and new operate on objects • The assignment operator ( = ) • Arithmetic operators + - * / % • Unary operators ++, --, *=, %= • Operator precedence • Arithmetic expressions are left associative • Assignment operators are right associative
  3. 3. 4.2.6 Boolean data and comparison operators • boolean values are true or false ( not 1 or 0) • Less than <, greater than >, equal to ==, less than or equal to <=, greater than or equal to >=, not equal != • AND &, OR |, XOR ^ • Short curcuit AND &&, OR ||
  4. 4. 4.2.8 Conditional operator • Alternative for if - else y = x > 4 ? 99: 9; Is the same as: if(x > 4) y = 99; else y = 9;
  5. 5. 4.2.9 Bitwise operators • Perform shifting of bits on integral types, preferably int of long • <<3 shifts all bits left 3 places. All new bits are 0 • >>>3 shifts all bits right 3 places. All new bits are 0 • >>3 shifts all bits right 3 places. The new bits are the same as the most significant bit before the shift.
  6. 6. 4.3.1 Casting and conversion • Casting assigns a value of one type to a variable of another type • If it is possible to lose information, an explicit cast is required long bigValue = 99L; int squashed = (int)bigValue;
  7. 7. 4.4.2 String and StringBuffer class • The String object can be used to store an arbitrary number of textual characters • Strings are immutable: They do not change • Concatenating two Strings results in the creation of another String • Use StringBuffer to hold Strings that will change
  8. 8. 4.5.1 Decision making and repetition • Control structures control the flow of statement execution • Three control structures: Sequence, selection or decision, repetition • In OOP, control structures exist within methods only • Selection control structure provides conditional execution (if-else) • Repitition control structure causes the computer to repeat certain actions (for <loop>, while <loop>, do <loop>)
  9. 9. 4.5.3 If statement • Basic if(x == 3) { System.out.println(“x equals 3”); } else { System.out.println(“x does not equal 3”); }
  10. 10. 4.5.4 Multiple condition If • Multiple condition if(a < b) { System.out.println(“a is less than b”); } else if (a < c) { System.out println(“a is less than c”); } else { System.out.println(“a is not less than b or c”); }
  11. 11. 4.5.5 Nested if • Nested If if(x == 3) { System.out.println(“x equals 3”); if( y == 4) { System.out.println(“ …and y equals 4”); } } else { System.out.println(“x does not equal 3”); }
  12. 12. 4.5.6 Switch statements • A conditional control structure that allows a value to be compared to more than one other value switch(test) { case 1: System.out.println(“test equals 1”); break; case 2: System.out.println(“test equals 2”); break; case 3: System.out.println(“test equals 3”); break; default: System.out.println(“test does not equal 1, 2 or 3”); break; }
  13. 13. 4.5.7 Loop • do while: Execution loops. Conditional evaluation at the end of the loop • while: Execution loops through the block. Conditional evaluation occurs at the start of the loop • for next: Specifies an initialization block, a conditional evaluation and a block that is executed in every loop
  14. 14. 4.5.11 Use of break, continue, and label • break is used to exit a block • continue is used to return to the start of the loop • label can be applied to a statement or block, then used with continue or break • break can be used to exit a labeled block • continue can be used to resume at a statement
  15. 15. 4.6.1 The java.lang.System class
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×