Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Exception

 
Misbha Ali
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across this code...I would appreciate if any one could make me understand this..specailly the new Object[] {rootCause} thing..
public DataServiceRiskWiseCheckedException(Code code, String debugInformation, Throwable rootCause, int severity)
{
this(code, new Object[] {rootCause}, debugInformation, rootCause, severity);
}
:roll:
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a constructor for a user-defined class with a long name; looks like an Exception class. A subclass of Exception is just like any other class; it can have various member variables, and they can be initialized in the constructor. All that's going on here is that some user-defined Exception subclass has a whole lot of member variables, and they all get initialized in the constructor, and that's all we can see. This constructor calls another constructor using "this()" by slightly adapting the arguments -- particularly, turning a Throwable argument into an Object[] argument.
The phrase new Object[] { rootCause } constructs a one-element-long array of Object; the element is initialized to point to the object pointed to by "rootCause".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic