• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there compile time exceptions in java?  RSS feed

 
Sri Dharan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there compile time exceptions in java? If yes, Any relation between checked exception and compile time exceptions?

 
shan raj
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think compile time exception and checked exceptions are the same. Please check this exceptions
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as "compile-time exceptions". The compiler can stop with an error if there is something wrong with your source code, but that's not the same as an exception.

There are checked exceptions and unchecked exceptions. All classes that subclass RuntimeException are unchecked exceptions. Maybe you are confused by the name of the class RuntimeException - that makes you think about "runtime" vs. "compile time", which makes you think that if there are "runtime" exceptions, there must also be "compile time" exceptions. But that's not the case.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you go through the Java™ Tutorials, you should find why a RuntimeException is called a RuntimeException. It is because it is thrown in the runtime, not because it occurs at runtime.
 
Sri Dharan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your valuable answers.I was misguided by some other posts/ forums.I got confused with the concept.

which should handle try,catch,finally block in checked exception or unchecked exception?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you see the Java Tutorials link I posted earlier? You should find most of your answers there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!