CSC152 2005S, Class 8: Strings, Continued Admin: * Attendance: * Reading (available now): Numbers * Handouts Overview: * Q and A * Lab * Reflection Q and A * What about backslashes? Interesting but problematic * In Scheme, how would I get the string (Sam says "Hello") * Brute force: (string #\S #\a #\m #\space #\s #\a #\y #\s #\space #\" ...) * Use an apostrophe (whoops ... that gives a symbol, not a character) * You are permitted to put a backslash before a " in the middle of a string: "Sam says \"Hello\"" * Problem: Backslash now has two potential meanings: * Backslash * Prefix to a special character * We eliminate the first * Hence, to get the backslash character, we use \\ If you haven't finished the lab, try to do so this weekend! * Tutors, Sunday 9-10 p.m. Hey, Sam, how do I get the first name? * Brute force, using only what you know so far (cleverly) String allInfo = in.readLine(); String lName = allinfo.substring(0,allinfo.indexof(":")); String allButLast = allinfo.substring(allinfo.indexof(":")).substring(1); String fName = allButLast.substring(0,allButLast.indexof(":")); * Using some fancy math String allInfo = in.readLine(); int firstcolon = allinfo.indexof(":"); int secondcolon = allinfo.indexof(":", firstcolon+1); String lname = allinfo.substring(0,firstcolon); String fname = allinfo.substring(firstcolon+1,secondcolon); Observation: N (intended) aspects to lab * Learn how to use the particular Java thingy * Learn why the designers at Sun chose to include particular methods * Do some problem solving * See some applications