Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

import java.lang.

Exception;

public class Testtry extends Exception {

public static void permuter(int i, int j, int []t){

try{

if (i==j) {

throw new NullPointerException("indices identiques");}

try{

int a;

a=t[i];

t[i]=t[j];

t[j]=a;

catch(ArrayIndexOutOfBoundsException e){

System.out.println ("Array Index is Out Of Bounds");

} finally { System.out.println("fin!");}

}
public static void main(String[] args) {

int [] v={1,2,3,4};

permuter(10,10,v);

for(int i=0;i<v.length;i++)

System.out.println(v[i]);

You might also like