Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Exception Handling

Program :To demonstrate exception handling.

Program
package exam;

import java.io.*;

public class MyArrExce
{
 	public static void main(String args[])
 	{
  		int n=0,i,j,t;
    		int a[]=new int[5];
 		DataInputStream in= new DataInputStream(System.in);
  		try	
  		{
  	 		System.out.println("Enter the no: of elements : ");
  			n=Integer.parseInt(in.readLine());
     			System.out.println("Enter the elements of array : ");
     			for(i=0;i
Output

Enter the no: of Elements :
5
Enter the elements of array :
23
6
36
99
10
The sorted array is :
99
36
23
10
6

Enter the no: of elements :
6
Enter the elements of array :
23
6
36
99
10
29
Error : Array index out of bounds.

Java Exception Handling is a post from ShoutToWorld - Let's Learn Let's Shout - Helping bloggers and developers.



This post first appeared on ShoutToWorld, please read the originial post: here

Share the post

Java Exception Handling

×

Subscribe to Shouttoworld

Get updates delivered right to your inbox!

Thank you for your subscription

×