hi there, Can you please tell me why is the following code gives a compilation error? Thanks, Yuki public class ThrowsDemo { static void throwMethod() { System.out.println("Inside throwMethod."); throw new IllegalAccessException("demo"); } public static void main(String args[]) { try { throwMethod(); } catch (IllegalAccessException e) { System.out.println("Caught " + e); } } }
Usha Vydyanathan
Greenhorn
Joined: Jan 03, 2001
Posts: 17
posted
0
Hi, Method signature should include throws clause. static void throwMethod() throws IllegalAccessException {} Usha