aspose file tools*
The moose likes Java in General and the fly likes IllegalStateException related Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "IllegalStateException related" Watch "IllegalStateException related" New topic
Author

IllegalStateException related

Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 76

Hi guys, was going through some common available Exceptions in Java just to learn and found this following example related to "IllegalStateException" from somewhere (sorry can't recall the source). Can any one please help me to understand here what the writer is trying to say?

The above program output is as follows:

Is there any good example(s) related to IllegalStateException?
Thank you so much...
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Faisal,

It looks like the original author is just demonstrating throwing exceptions. From the code you posted, you could replace IllegalStateException with another one, and get the same meaning.

John.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

just continue the John post!.

when you throw any exception under the method its become necessary in java to have a try-catch between method call
OR throws this example under the caller method. to handle that specific exception.

a little reading may help you more.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

continuing what john and muhammad said, the author is just demonstrating exception handling. i can't imagine a scenario where i would only have one line of code in a try block and all it did was throw an exception.


SCJP
Visit my download page
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18165
    
    8

It's possible the writer was trying to say something, but doing a bad job of it. Based on the presence of several misspellings, I wouldn't be surprised.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalStateException related
 
Similar Threads
Finally block executing before catch PRoblem
Unreachable
Nested Try/Catch
Jane's study notes about exception handling
When to use try/catch and throw ?