• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Correct me if I wrong

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The exceptions thrown by API methods like NumberFormatException ,IllegalArgumentException,ArrayIndexOutOfBoundsException are programatically thrown.

and JVM thrown exceptions are StackOverflowError,NullPointerException,ClassCast exception
Although we can explicitly through these exceptions
 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "programmatically thrown" and "JVM thrown"?
 
Bhavesh Saraswat
Greenhorn
Posts: 18
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always throw anything which is throwable from your code. Throwable is at the top of the hierachy. So in this way you can throw any exception of error you want from your code and also catch the same. But it is recomonded that you only throw exception or error which is more relevant and easy to understand during debuging.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahtab Alam wrote:
The exceptions thrown by API methods like NumberFormatException ,IllegalArgumentException,ArrayIndexOutOfBoundsException are programatically thrown.


Two of them are. ArrayIndexOutOfBoundsException is thrown by the JVM, though, whenever you try to access an array index that doesn't exist.

You can throw any exception programmatically. But some are only thrown that way - meaning that somewhere in the source code (either yours or an API) there's a statement that says "throw new ...".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic