Lecture 3

Fall 2018

Narges Norouzi

Recap

  • What are the primitive data types?

  • How to declare variables of different types?

  • How to assign values to variables?

  • What are the operations defined on different primitive data types?

  • How to create a java file and run a java program? we will also see more today.

Assignment overview

Control Statements

  • In order to control the flow/order of running the code:
    • if statement
    • while statement
    • do-While statement
    • for statement
    • switch statement
    • return, break, continue

if ... else ...

 

if (boolean expresion)

      stmt 

else

      stmt

 

while ... 

 

while (boolean expression)

      stmt 

 

do ... while

do 

      stmt 

while (boolean expression);

5 minutes break

for ...

 

for (initial stmt; end condition; increment stmt)

      stmt 

 

Switch ... case ...

switch (expression){

      case option1:

           stmt;

           break; 

      case option2:

           stmt; 

           break;

     default:

          stmt;

}

 

Zybooks chapters we covered

  • Chapter 3 (some sections)
  • Chapter 4 (some sections)

CMPS12A - Lecture 3

By Narges Norouzi

CMPS12A - Lecture 3

  • 1,841