On Wed, 2 Jun 2004 19:57:12 +0800, M wrote:
> Hi all, I'm learning Java 2 by myself and find question for help.
Please direct your quetions to
c.l.j.help for the moment.
<http://www.physci.org/codes/javafaq.jsp#cljh>
> I'm testing the System.in.read() method and tried the following program:
....
> My question are:
> (1) if I just comment out the "throws IOException" in the main, I
> just got compilation error! Is the any condition I can tell whether
> I have to throw something or not?
'JavaDocs'
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#in>
<http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read()>
The second link will most likey break because
of the '()', find your way from here..
<http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#method_summary>
> (2) If I entered more than 10 characters in the above test, I didn't
> get overflow error. Why?
Your code only reads the size of the array, 10
characters, then iterates through the existing 10.
Try entering 5..
--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology