-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotes0929.txt
More file actions
51 lines (35 loc) · 1002 Bytes
/
Notes0929.txt
File metadata and controls
51 lines (35 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Aim: How do conditional statements work in Java?
Do Now: Pick a language (not java) and perform the following tasks
1) Find the product of 4 and 6
2) Find the remainder of 105 / 6
3) Add 1 to a variable x
Note on operators in java
Arithmetic operators
+, -, *, /, %
%: mod operator (remainder)
Division is dependant on the types used!
<integer> / <integer> ==> <integer>
Integer division truncates the value, no
rounding occurs.
All other combinations will result in a
floating point type.
11 / 2 ==> 5
11 / 2.0 ==> 5.5
+=, -=, *=, /=, %=
Compound assignment operators
x+=y <==> x = x + y
++, --
Increment/decrement operators
The same as adding/subtracting 1 to a variable
int x = 4;
x++; // x becomes 5
x++ means return x and then add 1 to it
++x means add 1 to x and then return it
Comparison operators
>, <, >=, <=, ==, !=
Return boolean values
!= inequality
Boolean operators
&& and
|| or
! not