1 /*
 2 *  This program illustrates the use of some String methods
 3 *
 4 * @ author Elizabeth Adams
 5 *
 6 *
 7 */
 8
ÏÏÏimport java.util.Scanner;
 9
ÏÕÖ×public class Quiz2bKEY
10
Ïϧ{
11
ÏϧÏÞßàpublic static void main (String [] args)
12
ÏϧÏϧ{
13
ÏϧÏϨ¹íÏString code;
14
ÏϧÏϨ¹íÏchar temp;
15
ÏϧÏϨ¹íÏScanner scan;
16
ÏϧÏϨ¹¹Ïscan = new Scanner(System.in);
17
ÏϧÏϧ
18
ÏϧÏϨ¹¹ÏSystem.out.println (" Please enter a string and hit return ");
19
ÏϧÏϨ¹¹Ïcode = scan.nextLine();
20
ÏϧÏϧ
21
ÏϧÏϨ¹¹ÏSystem.out.println (" The string you entered is : " + code);
22
ÏϧÏϧ
23
ÏϧÏϨ¹¹ÏSystem.out.println (code.length());
24
ÏϧÏϨ¹¹ÏSystem.out.println (code.charAt(13));
25
ÏϧÏϨ¹¹ÏSystem.out.println (code.substring(18,20));
26
ÏϧÏϧ
27
ÏϧÏϨ¹¹´try
28
ÏϧÏϧÏϧ{
29
ÏϧÏϧÏϧ
30
ÏϧÏϧÏϨ¹¹ÏSystem.out.println (code.charAt(50));
31
ÏϧÏϧÏϧ}
32
ÏϧÏϧÏϧÏðîìcatch (StringIndexOutOfBoundsException  sioobe)
33
ÏϧÏϧÏϧÏϧ{
34
ÏϧÏϧÏϧÏϨ¹¹ÏSystem.out.println (" index 50 doesn't exist" );
35
ÏϧÏϧÏÏ©ÏÏ©}     
36
ÏϧÏϨ¹³´if (code.charAt(5) == 'A')
37
ÏϧÏϧÏ6¾¹¹ÏSystem.out.println ( "found an A at index 5"  );
38
ÏϧÏϧÏö´else
39
ÏϧÏϧÏȾ¹¹ÏSystem.out.println (" character at index 5 wasn't an A" );
40
ÏϧÏÏ©}
41
ÏÏ©}
42   
43
44