Answer on Question #63999, Programming & Computer Science / Java | JSP | JSF
public class Main {
public static void main(String[] args)
{
}
public int DoIt(){
int [] a = new int[10];
int temp = a[2];
try
{
String a1 = null;
String b = a1.toUpperCase();
System.out.println("\n departing DoIt()");
System.out.println("\n in try zone");
}
catch (ArithmeticException e)
{
System.out.println("\n caught arithmetic exception inside DoIt()");
}
catch (Exception w)
{
System.out.println("\n caught exception inside doIt()");
throw new IndexOutOfBoundsException("temp = a[12]");
}
finally
{
System.out.println("\n finally inside DoIt()");
}
System.out.println("\n after try ::doIt()");
return temp;
}
void one()
{
try
{
int x = DoIt();
System.out.println("\n after calling DoIt()");
}
catch (ArithmeticException e)
{
System.out.println("\n caught arithmetic exception ");
}
}
}
catch (Exception w)
{
System.out.println("\n caught exception ");
}
finally
{
System.out.println("\n done doing it");
}
System.out.println("\n outta here...bye");
}**Error: (13, 20) java: variable a is already defined in method DoIt()**
Pic. 1 Results
We can't use two different variables with the same name.
Answer provided by www.AssignmentExpert.com