K
kvnsmnsn
I've got a file "DefaultIntValue.java" that implements interface
<IIntValue> which is a descendant of <IValue> which requires it to
have <writeObject()> and <readObject()> methods, and four other files
that do similar things except that instead of reading and writing
<int>s they read and write <double>s, <float>s, <long>s and <String>s.
I originally defined the "DefaultIntValue.java" methods like so:
public void writeObject ( ObjectOutputStream isOut)
{
isOut.writeInt( integer);
}
public void readObject ( ObjectInputStream isIn)
{
integer = isIn.readInt();
}
But when I compiled these "DefaultIntValue.java" methods the compiler
told me "Unhandled exception type IOException" for both methods, and
got identical complaints for each of the other four files.
So I went in and changed my methods like so:
public void writeObject ( ObjectOutputStream isOut)
throws IOException
{
isOut.writeInt( integer);
}
public void readObject ( ObjectInputStream isIn)
throws IOException
{
integer = isIn.readInt();
}
and did similar changes to each of the four other files and then com-
piled, and the message the compiler gave me was, "Exception
IOException is not compatible with throws clause in
IValue.writeObject(ObjectOutputStream)" for <writeObject()> and "Ex-
ception IOException is not compatible with throws clause in
IValue.readObject(ObjectInputStream)" for <readObject()>. I got simi-
lar errors for each of the four other files.
Can anyone tell me what these compilation errors mean and what I have
to do to get these files to compile? Any feedback would be greatly
appreciated.
---Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
<IIntValue> which is a descendant of <IValue> which requires it to
have <writeObject()> and <readObject()> methods, and four other files
that do similar things except that instead of reading and writing
<int>s they read and write <double>s, <float>s, <long>s and <String>s.
I originally defined the "DefaultIntValue.java" methods like so:
public void writeObject ( ObjectOutputStream isOut)
{
isOut.writeInt( integer);
}
public void readObject ( ObjectInputStream isIn)
{
integer = isIn.readInt();
}
But when I compiled these "DefaultIntValue.java" methods the compiler
told me "Unhandled exception type IOException" for both methods, and
got identical complaints for each of the other four files.
So I went in and changed my methods like so:
public void writeObject ( ObjectOutputStream isOut)
throws IOException
{
isOut.writeInt( integer);
}
public void readObject ( ObjectInputStream isIn)
throws IOException
{
integer = isIn.readInt();
}
and did similar changes to each of the four other files and then com-
piled, and the message the compiler gave me was, "Exception
IOException is not compatible with throws clause in
IValue.writeObject(ObjectOutputStream)" for <writeObject()> and "Ex-
ception IOException is not compatible with throws clause in
IValue.readObject(ObjectInputStream)" for <readObject()>. I got simi-
lar errors for each of the four other files.
Can anyone tell me what these compilation errors mean and what I have
to do to get these files to compile? Any feedback would be greatly
appreciated.
---Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_