-
Exciting Question
Hi friends
if its not an exciting question Sorry! it's a doubt for me
Assume i have a function, and i calculate some value of say "yyy"(variable). while calculating if i get value of yyy=-1000 i.e in negetive value. I have to raise the exception that" invalid value" and my programm should continue.
this is just like, if i got wrong array index, if i put try cacth of ArrayIndexoutofBounds exception, my program should continue without halting.
How to write throwing exception and continue functionality for my program (variable yyy.) . please Give ana example????
it's really urgent for me..
Thans
Sona
-
Re: Exciting Question
Code is
public class Sample2
{
public static void main(String[] args)
{
try
{
int i = -5 ;
if( i == -5 )
throw new Exception("sa");
}
catch ( Exception e)
{
System.out.print("Invalid value");
}
}
}