Howdy. 

Expressions: 1 + 2

System.out.println( 1 + 2 ); 

int a; // declare a as an int variable 

Named location that can keep values inside. 

a = 3; 

System.out.println( a ); // prints 3

a = 5; 

System.out.println( a ); // prints 5

int x = 5; // declaring and initializing at the same time

int m, n, u = 5, v; // four variables declared one initialized as well 

What do you think this means:

a = a + 1; // what does this mean? 

System.out.println( a ); // prints ...

Welcome to DrJava.  Working directory is C:\Users\dgerman
> int a;
> a = 3;
> System.out.println( a );
3
> a = 5;
> System.out.println( a );
5
> a < 6
true
> a == 6
false
> a == a + 1
false
> a
5
> a = a + 1
6
> a == 6
true
> a
6
>

More about operators and shortcuts:

Welcome to DrJava.  Working directory is C:\Users\dgerman
> 3 == (2 + 1)
true
> 3 != (2 + 5)
true
> int a = 3;
> a = a + 1;
> a = a + 1;
> a = a + 1;
> a = a + 1;
> a
7
> a = a + 7;
> a
14
> a += 5; // shortcut for a = a + 5
> a
19


From now on I would like you to bring to school (class) a half a
page summary entitled: "Previously on C212" and in it discuss what
has happened in class up to that point. Now let's solve some exercises

1 < 3

and or not

   a      !a
  true   false 
  false  true 

   a      b      a && b 
  true   true    true 
  true   false   false 
  false  true    false 
  false  false   false 

   a      b      a || b 
  true   true    true 
  true   false   true 
  false  true    true 
  false  false   false 

1 - 2 + 3 is not the same as 1 - (2 + 3)

1 - 2 * 3 is also not the same as (1 - 2) * 3

Please consider ! as unary minus, && as * and || as +. 

What do you get for

false && false || true 
--------------
    false      || true 
    ------------------
          true 

The other one comes up as false, so the parens matter. 

Simplify b == true when b is a boolean variable. 

To simplify means to say the same thing with fewer resources. 

  
        Expression              Simplification 

 b   |  b == true               b 
-----+---------------------------------------------- 
true | true                     true 
false| false                    false 

This shows the two expressions are equivalent (same values for same inputs). 

Simplify b == !b please. 

 b      b == !b                 false 
----------------------------------------------------
true    false                   false 
false   false                   false 

 b      b == false              !b 
----------------------------------------------------
true    false                   false 
false   true                    false 

Let's simplify now (x < 5) && (x < 25) if x is an int variable.

Answer: x < 5 this seems to be the answer (see below) 

Another answer: x < 25 that seems to not be the answer 

  x                             5             25 
 ----------------------------------------------------------------
  x < 5               T T T T   F    F F F    F    F F F F 
 ----------------------------------------------------------------
  x < 25              T T T T   T    T T T    F    F F F F 
 ----------------------------------------------------------------
  x < 5 && x < 25     T T T T   F    F F F    F    F F F F 

int n, m;                     n+m
                             -----
                  n            2            m
------------------+------------+------------+---------------------
                  |<-------- |n-m| -------->|

Math.max(n, m) = (Math.abs(n - m) + (n + m))/2

if (n < m) { // this is the "then" branch 
  System.out.println(m + " is the largest of the two."); 
} else { // the "else" branch 
  System.out.println(n + " is the largest of the two.");   
}

The rule that I want to enforce is that we should curly braces to
delimit the branches all the time. The truth is though that if the
branches have one only one statement in them then the curly braces
are not necessary. This is to say the code above is exactly identical
with the code 

if (n < m) 
  System.out.println(m + " is the largest of the two."); 
else 
  System.out.println(n + " is the largest of the two.");   

My question for next time is this: 

  given the shortcut expressed above how many curly braces
  can you remove from the program without losing correctness

Math.random() which produces random numbers in [0, 1)

We now introduce two operators. 

Welcome to DrJava.  Working directory is C:\Users\dgerman
> int i;
> i = 3;
> i
3
> i = i + 1;
> i
4
> i += 1;
> i
5
> i++ // will increment i to 6 but will print 5
5
> i
6
> i++ // will increment i to 7 but what I get here as a value is 6
6
> i
7
> ++i // make i 8 and that's also the value I get 
8
> i
8
>