• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IllegalStateException related

 
Ranch Hand
Posts: 88
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28263
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic