I am confused about types of exceptions in Java. On many tutorial websites I have seen that two types of exception are there in java
- Compile time exception
- Run time exception
But when I talked with some java masters, according to them there is no such thing like compile time exception. They said it was compile time errors not exception, as well as I found nothing about compile time exception in Java docs. But when I run following program
File f = new File("C:/Documents and Settings/satyajeet/Desktop/satya.txt");
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String s = br.readLine();
System.out.println(s);
I got below output if try catch not provided.
D:\jdk1.6.0_19\bin>javac Testing.java
Testing.java:7: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
FileReader fr=new FileReader(f);
^
Testing.java:9: unreported exception java.io.IOException; must be caught or declared to be thrown
String s=br.readLine();
^
2 errors
So should I consider this Error or compile time exception?