This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Exception" Watch "Java Exception" New topic
Author

Java Exception

Misbha Ali
Greenhorn

Joined: Jul 22, 2003
Posts: 7
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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".


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Exception