1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15import java.io.*;
16
17public class E05 {
18
19 private final static int N=8;
20
21 public static void main(String[] args)
22 throws IOException
23 {
24 String t = "tiger";
25
26 boolean done;
27
28 DataInputStream dIS = new DataInputStream(System.in);
29 Reader kR = new BufferedReader(new InputStreamReader(dIS));
30 StreamTokenizer kTokens = new StreamTokenizer(kR);
31
32 do {
33 // get the index interactively from keyboard.
34 System.out.print("Enter an index: ");
35 System.out.flush();
36 kTokens.nextToken();
37 int index = (int) kTokens.nval;
38
39 done = true;
40
41 try {
42 System.out.println("Char at position " + index + " is " + t.charAt(index));
43 }
44 catch(StringIndexOutOfBoundsException e) {
45 done = false;
46 System.out.println(e);
47 }
48 }
49 while(!done);
50 }
51
52}