public class TechnoSample
{
public static void main(String args[])
{
int i = 2;
try
{
double x = Math.random() * 2;
System.out.println(x);// 0.4545
i *= (int) Math.floor(x);
System.out.println(i);// 0
if (i > 1)
System.out.println("No arithmetic exception");
}
catch (ArithmeticException ae)
{
System.out.println("Arithmetic exception cautht");
}
finally
{
System.out.println(i);
}
}
}
Out Put:--
1.5059545776537702
2
No arithmetic exception
2
No comments:
Post a Comment