whis is the IllegalArgument Exception in java? or define IllegalArgument Exception with exp?
IllegalArgument Exception is thrown when an illegal argument is sent to the method.
Example
import java.io.*; public class GetStackTraceAsString{ public static String getStackTrace(Throwable throwable) { Writer writer = new StringWriter(); PrintWriter printWriter = new PrintWriter(writer); throwable.printStackTrace(printWriter); return writer.toString(); } public static void main (String[]args){ final Throwable throwable = new IllegalArgumentException("Hello"); System.out.println( getStackTrace(throwable) ); } }
Ads