Difference Between throw and throws in Java Last Updated : 07 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite: Throw and Throws in Java The throw and throws are the concepts of exception handling in Java where the throw keyword throws the exception explicitly from a method or a block of code, whereas the throws keyword is used in the signature of the method. The differences between throw and throws in Java are: S. No. Key Difference throw throws 1.Point of UsageThe throw keyword is used inside a function. It is used when it is required to throw an Exception logically.The throws keyword is used in the function signature. It is used when the function has some statements that can lead to exceptions.2.Exceptions ThrownThe throw keyword is used to throw an exception explicitly. It can throw only one exception at a time.The throws keyword can be used to declare multiple exceptions, separated by a comma. Whichever exception occurs, if matched with the declared ones, is thrown automatically then.3.SyntaxSyntax of throw keyword includes the instance of the Exception to be thrown. Syntax wise throw keyword is followed by the instance variable.Syntax of throws keyword includes the class names of the Exceptions to be thrown. Syntax wise throws keyword is followed by exception class names.4.Propagation of Exceptionsthrow keyword cannot propagate checked exceptions. It is only used to propagate the unchecked Exceptions that are not checked using the throws keyword. throws keyword is used to propagate the checked Exceptions only. Examples 1. Java throw Java // Java program to demonstrate the working // of throw keyword in exception handling public class GFG { public static void main(String[] args) { // Use of unchecked Exception try { // double x=3/0; throw new ArithmeticException(); } catch (ArithmeticException e) { e.printStackTrace(); } } } Output: java.lang.ArithmeticException at GFG.main(GFG.java:10) 2. Java throws Java // Java program to demonstrate the working // of throws keyword in exception handling import java.io.*; import java.util.*; public class GFG { public static void writeToFile() throws Exception { BufferedWriter bw = new BufferedWriter( new FileWriter("myFile.txt")); bw.write("Test"); bw.close(); } public static void main(String[] args) throws Exception { try { writeToFile(); } catch (Exception e) { e.printStackTrace(); } } } Output: java.security.AccessControlException: access denied ("java.io.FilePermission" "myFile.txt" "write") at GFG.writeToFile(GFG.java:10) Comment More infoAdvertise with us Next Article Difference Between throw and throws in Java A AnushkaKhattri Follow Improve Article Tags : Misc Java Exception Handling Java-Exceptions java-basics +1 More Practice Tags : JavaMisc Similar Reads throw and throws in Java In Java, exception handling is one of the effective means to handle runtime errors so that the regular flow of the application can be preserved. It handles runtime errors such as NullPointerException, ArrayIndexOutOfBoundsException, etc. To handle these errors effectively, Java provides two keywords 5 min read Difference Between Callable and Runnable in Java java.lang.Runnable is an interface that is to be implemented by a class whose instances are intended to be executed by a thread. There are two ways to start a new Thread â Subclass Thread and implement Runnable. There is no need of sub-classing Thread when a task can be done by overriding only run() 3 min read Difference Between System.out.println() and System.err.println() in Java System.out is a PrintStream to which we can write characters.  It outputs the data we write to it on the Command Line Interface console/terminal. It is mostly used for console applications/programs to display the result to the user. It can be also useful in debugging small programs. Syntax: System.o 2 min read Method Class | getExceptionTypes() Method in Java The java.lang.reflect.Method.getExceptionTypes() method of "Method class" returns an array of Exception Type Class Objects declared to be thrown by the method object to handle exception inside the method. All the exceptions handled by method using thrown clause, are returned as array of Class object 3 min read Method Class | getGenericExceptionTypes() Method in Java The getGenericExceptionTypes() method of java.lang.reflectMethod class returns an array of Type objects representing Exceptions thrown by the method object to handle exception. All the exceptions handled by method using thrown clause are returned as array of Type objects using this method. This meth 4 min read Like