Posted by À±°æ±¸ on April 12, 1997 at 08:36:44:
In Reply to: [Q] java.io.IoException must be caught ....? posted by ¾çÁ¤À± on April 12, 1997 at 03:09:41:
System.inÀº InputStream Ŭ·¡½º ÀνºÅϽºÀÔ´Ï´Ù.
API ¹®¼¸¦ »ìÆ캸¸é InputStream.read() µµ±¸´Â ´ÙÀ½°ú °°ÀÌ ¼±¾ðµÇ¾î ÀÖ½À´Ï´Ù.
public abstract int read() throws IOException
class IfElseName {
public static void main (String args[]) {
char firstInitial=0;
System.out.println("Enter your first initial:");
try {
firstInitial = (char) System.in.read();
}catch(java.io.IOException e) {
e.printStackTrace();
}
if (firstInitial == -1)
System.out.println("Now what kind of name is that!?");
else if (firstInitial == 'j')
System.out.println("Your name must be Jules!");
else if (firstInitial == 'v')
System.out.println("Your name must be Vincent!");
else if (firstInitial == 'z')
System.out.println("Your name must be Zed!");
else
System.out.println("I can't figure out your name!");
}
}