| | |
IllegalStateException?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I've looked and looked for some good material on this exception, but I can't find anything helpful. I just don't understand it. It's suppose to be caught or thrown whenever a method is called when not suppose to be...But won't other exceptions be caught or thrown in it's place? If you have any comments or anything to say, please post!
but then u never catch this expection in the first place. if you want to catch all expections can try using this
Java Syntax (Toggle Plain Text)
try {} catch(Exception e) { }
Think of calling a method to do a database query on a database that is closed.
Or calling a read method on a stream that's past the end of the data.
Or calling write methods on a readonly file.
Note that these won't throw IllegalStateException in Java but they could (they throw something more specific).
In general it's there to indicate you're trying to do something with an object that at that moment isn't possible to do with it.
Or calling a read method on a stream that's past the end of the data.
Or calling write methods on a readonly file.
Note that these won't throw IllegalStateException in Java but they could (they throw something more specific).
In general it's there to indicate you're trying to do something with an object that at that moment isn't possible to do with it.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by jwenting
Note that these won't throw IllegalStateException in Java but they could (they throw something more specific).
It is. But remember File et.al. typically throw IOExceptions which don't derive from IllegalStateException.
IllegalStateException is a RuntimeException, which is why you'll find few cases of it being explicitly caught (usually these are used to indicate programming errors rather than runtime problems, despite what their name suggests) while IOException is a regular Exception which requires catching at some point.
IllegalStateException is a RuntimeException, which is why you'll find few cases of it being explicitly caught (usually these are used to indicate programming errors rather than runtime problems, despite what their name suggests) while IOException is a regular Exception which requires catching at some point.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- [urgent] JSP problem (JSP)
Other Threads in the Java Forum
- Previous Thread: Reading stream with two xml files in
- Next Thread: java for palm/PDA's
| Thread Tools | Search this Thread |
3d @param affinetransform android api applet application arc arguments array arrays automation binary bluetooth byte capture chat class classes click client code color compare component count database design detection eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image input integer j2me java java.xls javaprojects jni jpanel julia keytool keyword linux list loop macintosh map method methods mobile netbeans newbie object os pong print problem producer program programming project projectideas read recursion replaysolutions rim scanner screen server set size sms sort sql string swing terminal threads time transforms tree ui web windows






