Paul Clapham wrote:Navin's question is essentially the same as "Why is there more than one Exception class?"
So why did the people who wrote the java.sql package decide they needed an SQLException? Couldn't they just throw Exception? And all those other hundreds of classes in the standard API which extend Exception? What's the point of having all of them?
Well, obviously it's because they can be used for a specific purpose. Just like any other class, if you need something for a specific purpose then you write it.
well thanks thats what i thought ,and one more thing is that why we create constructor of our newlly created Exception clsss because we never through error saying that what we have wrote in a parameter
say like
and some where down we write something like
throw new MyException(" Unknow error ");
but we never display that error on the console or to our user , instead we will use try catch and in catch we will write something more specific related with the error or exception ,so now the question is why we write constructor and give parameters to those constructors ???