Nagendran
IllegalArgument
1 Answer(s)      a year and 2 months ago
Posted in : Java Interview Questions

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 Pages:
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.