
if i have search program and if the search for a particular string fails the method should return an exception or error message. Basically user defined exception, how do i do that?

Hi,
Thanks for the response. I know the basic representation of exception class and its creation. the example had a very basic thing, if a condition fails then raise exception.
What if i have a for loop for searching and in the for loop i did not find the string which i was looking for then i need to raise an exception.
void fun()
{
for(int i = 0; i }
} If the method was not able to find the "some string" then i need to raise an exception saying "Couldn't find"... Cheers!if(array[i].equals("some string")
{
break;
}
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.