Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
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
 

 

 

DMCA.com