IllegalArgument

IllegalArgument

whis is the IllegalArgument Exception in java? or define IllegalArgument Exception with exp?

View Answers

March 28, 2012 at 1:04 PM

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) );
 }
}









Related Tutorials/Questions & Answers:
IllegalArgument
IllegalArgument  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

Ads