Week 2 Flashcards
Double quotes around the text =
a String of characters
+ in a String =
Strong concatenation operator
Escape Sequences
\t = tab \n = newline \r = carriage return \” double quote \’ = single quote \\ = backslash
variable
is a name for a “location” in memory
a variable must be declared with…
the type of information that it will hold
a bit can be either…
a 1 or a 0
a string of N bits can be used to represent…
2 to the Nth different values
8 primitive data types in Java
- integer
- byte 8 bits
- short 16 bits
- Int 32 bits
- long 64 bits
- floating
- float 32 bits
- double 64 bits
- character
- char 65,536 unique characters
- boolean
- boolean (true or false)
an expression is made up of one or more …
variables, operators, and/or method invocations that evaluates to a single value.
arithmetic expressions
+, -, *, /, %(remainder aka modulus)
increment operator
++
decrement operator
–
x += count is the same as…
x = x+count
Relational Operators (for Boolean Values)
== Equal != Not equal < less than <= less than or equal > greater than >=greater than or equal
Data conversions can occur in three ways…
- assignment conversion – a value of one type is assigned to a variable of another. Allows only widening conversions. (ex. An int into a double)
- promotion – happens when operators in expressions converts their operands. Happens in math equations.
- casting – allows narrowing conversions and widening conversions. They type in parenthesis is placed in front of the value being converted. (result = (double) total/count)