LECTURE OCTOBER 20 2004 ASSIGNMENTS 10/22 CodeLab 7 TEST CASES What? - *error case* - *normal case* - *end case* Example? - skydiving, when to pull the parachute? CHARACTERS What? - data type How? - char What? - literal How? - surround the character with single quotes, e.g. 'A' What? - character data type declaration How? - char = ''; What? - internal representation on a computer How? - combination of 1s and 0s Why? - so people can exchange data easily What? - ASCII - American Standard Code for Information Interchange - widely used character coding scheme - not all characters are printable - sufficient for common English, but not for many other languages How? - see table in book on page 517 - 128 total characters - requires 7 bits for representation - 1 byte is actually used - 128 leftover codes are generally used for manufacturer-specific non-standard symbols Why? - 256 characters not enough for foreign languages What? - Unicode - full name is Unicode Worldwise Character Standard - established by the Unicode Consortium How? - 34,168 distinct characters - 2 bytes per character - same as ASCII codes where overlap What? - Java characters How? - Unicode What? - using Unicode for Java IO How? - Operating System and development tool must also support What? - converting between integer ASCII/Unicode encodings and Java characters How? - to get the numerical encoding, cast a char to an int - to get a char, cast an int to a char (but the int must be within the encoded range) What? - comparing characters How? - like numbers - returns comparison of ASCII encoding - letters sort alphabetically - capital letters sort before lower case