- learn to use existing classes - later, learn to define own - Java API - application programming interface - documentation for the standard classes - null - reserved word - means no object - \n: newline character - method composition: use result of one method as arg for another - JOptionPane for output - display computed result to user - window types - in graphical user interface (GUI) env - general purpose frame, e.g. JFrame - special purpose dialog - e.g., JDialog - method showMessageDialog - first argument - controlling frame object - dialog positioned at center of this, or, if no arg, of screen - creates instance of JDialog internally - class method - don't need to create object to use it - just use . - String - textual values - sequence of chars surrounded by double quotes - explicit use of new optional - methods - substring - first argument - beginning position - note that position numbers count from 0 - is displayed - second argument - end position - is not displayed - creates new string - original string left intact - generates error if given illogical arguments - length: return # chars in str obj - indexOf - locate index position of substring within another string - returns position of first char of substring - returns -1 if substring not found - case-sensitive - returns first occurrence if multiple exist - concatenation - create a new string from two existing ones - + - cannot concatenate null - many others - Date - time instance - millisecond (ms) precision - in java.util package - automatically set to time created - obtained from OS - toString method converts to human-readable - internally represented as elapsed time since epoch - epoch: Jan 1, 1970 00:00:00 GMT - GMT: Greenwich mean time - use GregorianCalendar for real dates - SimpleDateFormat - change display format of Date - java.text package - pass formatting string when create instance of SimpleDateFormat - formatting string case-sensitive - common letters for formatting string p. 68 - JOptionPane for input - showInputDialog method - access input by assigning return result to variable - returns null if cancel clicked - returns empty string if nothing entered & OK clicked Quick Check: 1. JOptionPane.showMessageDialog(null, "I Love Java"); 2. JOptionPane.showMessageDialog(null, "Shoppint List:\n\tApple\n\tBanana\n\tLowfat Milk"); 1. ocha 2. 0 3. 8 4. abcab 1. SimpleDateFormat sdf; sdf = new SimpleDateFormat("MM-dd-yyyy"); JOptionPane.showMessageDialog(null, sdf.format(new Date()); 2. Today is Jul 04, 1776 1. initial = JOptionPane.showInputDialog(null, "What is your middle initial?"); 2. dorm = JOptionPane.showInputDialog(null, "What's the name of your dorm?");