• 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

Difference between Exceptions thrown by JVM and thrown Programatically

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends
K&B says that" programmatically thrown Exceptions means Created by an application and/or API developer" .they give example as "NumberFormatException".i am confused that since it is a Runtime Exception why other runtime exceptions like ClassCastException does not fall in this category.where is the actual difference.
how we decide that this Exception is thrown by JVM or Programatically.i am very confused.Please help.
Thanking You.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not about runtimeExceptions. Any exception that is thrown by writing a throw new ExceptionType syntax is a programmatic exception. So when the NumberFormatException is thrown by suppose Integer.parseInt(), then internally the code would be doing something like this



Now I don't want to say that the parseInt method looks actually like that but I just want to clear the concept
 
aruna dabas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankit.You always clear the concepts very nicely.maximum number of my doubts gets clear by your posts.
 
aruna dabas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so in this way can we say that InterruptedException can be a programmatically exception.
 
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ummmm,

Interreptud Exception is checked exception, so always thrown by programmatically.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is really not an important distinction, but the difference is that "programmatic" exceptions are thrown by Java code (either yours, or in a library) while exceptions "thrown by the JVM" means just that: created and thrown from the native code that makes up the JVM. Any type of exception can be thrown programmatically, while there is a finite list of exception types that the JVM itself might throw.

From the perspective of a Java programmer calling a method, there's no way to tell whether an exception that came from that call was thrown programmatically or not -- nor is it especially useful to know.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ernest Friedman-Hill wrote:there is a finite list of exception types that the JVM itself might throw.



This must clear it all ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic