gurpeet singh wrote:i'm not able to understand the difference between two. i know that ArrayIndexOutOfBoundsException is a JVM thrown exception but what if i write in my source code as "throw new ArrayIndexOutOfBoundsException". here i'm throwing ArrayIndexOutOfBoundsException programmatically in my source code. does that make ArrayIndexOutOfBoundsException as programmatically thrown . what is the exact definition ? please explain with an example ?
Tell the difficulties that i am difficult.
saloni jhanwar wrote:
gurpeet singh wrote:i'm not able to understand the difference between two. i know that ArrayIndexOutOfBoundsException is a JVM thrown exception but what if i write in my source code as "throw new ArrayIndexOutOfBoundsException". here i'm throwing ArrayIndexOutOfBoundsException programmatically in my source code. does that make ArrayIndexOutOfBoundsException as programmatically thrown . what is the exact definition ? please explain with an example ?
As named "programmatically thrown", what are you throwing doesn't mean, matter is that you are throwing.
gurpeet singh wrote:
saloni jhanwar wrote:
gurpeet singh wrote:i'm not able to understand the difference between two. i know that ArrayIndexOutOfBoundsException is a JVM thrown exception but what if i write in my source code as "throw new ArrayIndexOutOfBoundsException". here i'm throwing ArrayIndexOutOfBoundsException programmatically in my source code. does that make ArrayIndexOutOfBoundsException as programmatically thrown . what is the exact definition ? please explain with an example ?
As named "programmatically thrown", what are you throwing doesn't mean, matter is that you are throwing.
so in that case does that mean ArrayIndexOutOfBoundsException is programmatically thrown exception ???
Tell the difficulties that i am difficult.
Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Sumit Patil wrote:Gurpreet,
What are your definitions for JVM thrown exceptions and Programmatically thrown exceptions?
gurpeet singh wrote:i still dont understand the difference between the two. is it like that all checked exceptions are programmatically thrown exceptions and all unchecked exceptions are JVM thrown ? is it right ?
Tell the difficulties that i am difficult.
saloni jhanwar wrote:
gurpeet singh wrote:i still dont understand the difference between the two. is it like that all checked exceptions are programmatically thrown exceptions and all unchecked exceptions are JVM thrown ? is it right ?
Using throw keyword you can throw anything error ,checked and unchecked.And when you create your own exception that is also called programmatically.
Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
gurpeet singh wrote:i still dont understand the difference between the two. is it like that all checked exceptions are programmatically thrown exceptions and all unchecked exceptions are JVM thrown ? is it right ?
gurpeet singh wrote:
so does that mean it all depends upon the context. i.e. normally ArrayIndexOutOfBoundsException is JVM thrown exception but if we explicitly throw it using throw keyword then it is programmatically thrown exception . am i right ? am not able to digest this ? there must be some difference between both of them ?
Tell the difficulties that i am difficult.
John Jai wrote:
gurpeet singh wrote:i still dont understand the difference between the two. is it like that all checked exceptions are programmatically thrown exceptions and all unchecked exceptions are JVM thrown ? is it right ?
Nope. As Saloni suggested you could throw any Exception in your program both checked and unchecked. If the API developers chose to throw RuntimeException, then it's a programmatically thrown Exception in that case.
Old threads - thread-1 thread-2
John Jai wrote:Normally as a programmer, you wouldn't throw a RuntimeException. They are meant to be thrown by the JVM.
gurpeet singh wrote:what is the exact definition ?
gurpeet singh wrote:
so does that mean it all depends upon the context. i.e. normally ArrayIndexOutOfBoundsException is JVM thrown exception but if we explicitly throw it using throw keyword then it is programmatically thrown exception . am i right ? am not able to digest this ? there must be some difference between both of them ?
gurpeet singh wrote:
so does that mean it all depends upon the context. i.e. normally ArrayIndexOutOfBoundsException is JVM thrown exception but if we explicitly throw it using throw keyword then it is programmatically thrown exception
Jeff Verdegan wrote:
John Jai wrote:Normally as a programmer, you wouldn't throw a RuntimeException. They are meant to be thrown by the JVM.
I sort of disagree. Error and its subclasses are primarily for the JVM, but it's not that uncommon for Java code--including that outside the core API--to throw RuntimeExceptions, or at least a few subclasses. Off the top of my head, I throw IllegalArgumentException and IllegalStateException under various conditions in my code.
Jeff Verdegan wrote:
John Jai wrote:Normally as a programmer, you wouldn't throw a RuntimeException. They are meant to be thrown by the JVM.
I sort of disagree. Error and its subclasses are primarily for the JVM, but it's not that uncommon for Java code--including that outside the core API--to throw RuntimeExceptions, or at least a few subclasses. Off the top of my head, I throw IllegalArgumentException and IllegalStateException under various conditions in my code.
ravi grk wrote:A checked exception is any subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.
Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream's read() method
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked.
With an unchecked exception, however, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String's charAt() method.
Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be, as they tend to be unrecoverable.
JVM thrown exceptions are runtime /unchecked exceptions-developer doen't know or can not handle those
develper thrown exception are checked exceptions
ravi grk wrote:A checked exception is any subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.
Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream's read() method
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked.
With an unchecked exception, however, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String's charAt() method.
Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be, as they tend to be unrecoverable.
JVM thrown exceptions are runtime /unchecked exceptions-developer doen't know or can not handle those
develper thrown exception are checked exceptions
Wendy Gibbons wrote:So I still think this the OP's book is making an arbitary and pointless distinction.