ethanhann_java-basics-to-intermediate
ethanhann_java-basics-to-intermediate
type size range of values Integer sign + +99 -or- Printing to console
byte 8-bit (-128 -> 127) - -99 System.out.print(String s); print s
signed add + 5+3=8 System.out.println(String s);
2's comp print s followed by newline
subtract - 5-3=2
System.out.println(); print a newline
short 16-bit (-32,768 -> 32,767) multiply * 5*3 = 15
signed Parse command-line args
divide / 5/3 = 1 int Integer.parseInt(String s);
2's comp
no
convert s to an int value
int 32-bit (-231 -> 231-1) fractional
double Double.parseDouble(String
signed part
s); convert s to a double value
2's comp
remainder % 5%3= long Long.parseLong(String s);
long 64-bit (-263 -> 263-1) 2 convert s to a long value
signed
Floating-Point add + 3.141 +
2's comp
Numbers 2.0 =
long 64-bit (0 -> 264-1) 5.141
unsigned
subtract - 3.141 -
float single-pr‐ (-3.40282347 x 1038 2.0 =
ecision -> 3.40282347 x 1.111
32-bit 1038)
multiply * 3.141 *
signed
2.0 =
double double- (-1.79769313486‐ 6.282
precision 231570 x 10308 ->
divide / 3.141 /
64-bit 1.7976931348‐
2.0 =
signed 6231570 x 10 308)
1.5705
char 16-bit (0 -> 65,535)
unsigned Boolean Operations
Unicode
Values Literals Operations Operators
character
true true and &&
boolean size not true / false
defined false false or ||
not !
Hello World
Check months
(month >= 1) && (month <= 12)
returns true if month is between 1 and 12