Chapter 2 slides Flashcards
what can be included in an identifier?
letters, digits, underscores, and dollar signs
what can an identifier start with?
a letter, an underscore, or a dollar sign. NO DIGITS
what can an identifier not be?
reserved words, true, false, or null
what must a char variable be encased in?
single quote, ‘…’ Ex. ‘A’
how should variables be named?
lowercase unless multiple words, then lowercase first word followed by capital letter of each other word with no spaces in between
how should class names be named?
no spaces, each word capitalized
how should constants be named?
capitalize all letters in word, use underscores as spaces
how to write exponent operations?
System.out.println(Math.pow(n1,n2)); // n1 raised to power of n2
how to write scientific notation?
(num)e+2 or (num)e2
augmented assignment operators
+=, -=, *=, /=, or %=. Means n += 8 -> n = n + 8
preincrement operators
++var and –var. Increase or decrease var by 1, then use the new var in the statement.
postincrement operators
var++ and var–. increase or decrease var by 1, but use the original var in the statement.
order of variable types
byte, short, int, long, float, double
how to show multiple decimals
multiply variable by 100, then divide by 100.0…