There are 3 types of Throwables in Java.
- Checked
Exceptions (Exceptionand down the chain, save forRuntimeException). These are checked by the compiler and must be caught when thrown. They represent an exceptional condition that is usually recoverable, e.g. when a referenced file is not found on the file system (seeFileNotFoundException). - Unchecked or runtime
Exceptions (children ofRuntimeException). These can be thrown without catching. They typically represent programming errors, for instance invoking methods on anullobject (seeNullPointerException). Errors. These are unchecked as well. They are thrown by the JVM when something very wrong is happening, typically beyond the developer's direct control (e.g. out of memory, seeOutOfMemoryError). Compiler errors are issued by the Java compiler when your code fails to compile, for various reason such as bad syntax, ambiguous calls, failing to catch a checkedException, etc. etc.
Types of Exception in Java - Stack Overflow
My personal definitive guide to (java) Exceptions
Exception handling in Java: Advanced features and types
[Java] Incompatible data types
What are you trying to do here? You have declared num to be an array, of length 10, containing Rational objects. That means that num[0], num[1], num[2], …, and num[9] are all individual Rational objects. The index to an array must be an integer: the 0th element of the array is num[0], the 3rd element is num[3], the 9th element is num[9], and so on. It doesn't make sense to use a Rational object as the index to an array. The expression num[u] doesn't make sense if u is a Rational object. What do you intend to mean by that?
Videos
There are 3 types of Throwables in Java.
- Checked
Exceptions (Exceptionand down the chain, save forRuntimeException). These are checked by the compiler and must be caught when thrown. They represent an exceptional condition that is usually recoverable, e.g. when a referenced file is not found on the file system (seeFileNotFoundException). - Unchecked or runtime
Exceptions (children ofRuntimeException). These can be thrown without catching. They typically represent programming errors, for instance invoking methods on anullobject (seeNullPointerException). Errors. These are unchecked as well. They are thrown by the JVM when something very wrong is happening, typically beyond the developer's direct control (e.g. out of memory, seeOutOfMemoryError). Compiler errors are issued by the Java compiler when your code fails to compile, for various reason such as bad syntax, ambiguous calls, failing to catch a checkedException, etc. etc.
Any "famous website" that said that should not be read. It is rubbish. There is no such thing as a "compile time exception". The Java Geeks you were talking to are correct1.
Actually, you probably misread or misunderstood what you read on those "famous sites". There are "compile time ERRORS" and "run time EXCEPTIONS".
In your example, what you have is a couple of compile time error message, that are due to errors in your code. The errors are there because your code does not handle exceptions correctly, but they are ERRORS nonetheless. And they are detected at compile time ... by the Java compiler.
1 ... and maybe it is time to stop using semi-derogatory labels like "geek" for them. It sounds like they deserve some respect.